i m learning a tutorial on fileupload in laravel. my file is not being uploaded. there seems to be problem at this code.
//move uploaded file
$destinationPath = 'uploads';
$file = move($destinationPath,$file->getClientOriginalName());
and where exactly i need to create a destination path
These are my full codes
uploadfile.php
<body>
<?php
echo Form::open(array('url' => '/uploadfile','files' => 'true'));
echo "Select the file to upload!";
echo Form::file('image');
echo Form::submit('Upload File');
echo Form::close();
?>
</body>
FileUploadController.php
<?php
namespace FirstProject\Http\Controllers;
use Illuminate\Http\Request;
class FileUploadController extends Controller
{
public function index(){
return view('uploadfile');
}
public function showUploadFile(Request $req){
$file = $req->file('image');
//display the fullname
echo "File Name: " .$file->getClientOriginalName();
echo "<br>";
//display file extension
echo "File Extension: " .$file->getClientOriginalExtension();
echo "<br>";
//display file realpath
echo "File Real Path: " .$file->getRealPath();
echo "<br>";
//display file size
echo "File Size: " .$file->getSize();
echo "<br>";
//display file mime type
echo "File Mime Type: " .$file->getMimeType();
//move uploaded file
$destinationPath = 'uploads';
$file = move($destinationPath,$file->getClientOriginalName());
}
}
?>
web.php
Route::get('/uploadfile','FileUploadController@index');
Route::post('/uploadfile','FileUploadController@showUploadFile');