I'm working on the database restore menu for an application I created, I'm using sqlite for my database, and I want to put my previously backed up database file to the database directory
backupAndRestore.blade.php
<form method="POST" action="/admin/backupAndRestore/restore" enctype="multipart/form-data">
<div class="file-field input-field">
<div class="btn">
<span><i class="material-icons">file_upload</i></span>
<input type="file" name="database" accept=".sqlite">
</div>
<div class="file-path-wrapper">
<input type="text" class="file-path" placeholder="Example: file_name.sqlite" readonly>
</div>
</div>
<button type="submit" class="btn">restore</button>
</form>
Route
Route::post('/admin/backupAndRestore/restore', 'DatabaseController@restore');
DatabaseController.php
public function restore(Request $request)
{
$database = $request->database;
$file_name = 'database2.sqlite';
$path = database_path($file_name);
file_put_contents($path, $database);
return $path;
}
my code works, the file is stored in the database directory, the problem is when I backup my database file size is 22kb, but when I restore it and I check the database directory, the file is 1kb size and when I open using sublime file contents as shown below
which I expect as shown below
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire