I figured it out it was something super simple sorry. I only recently learned that 'return' can only be used once in a function otherwise that's where it stops. I was using old code and finally saw this. Thanks anyways :)
Video upload form results in browser displaying only absolute path and not the redirect
Hello I'm having trouble understanding why when with my video upload form the video does copy (development server, upload otherwise) the video yet with a return redirect()->route(), and a couple of other return options I've tried, it returns the absolute path: "/var/www/..." in the browser in plain text nothing else.
Here is my controller method ('MovieController@postUpload'):
public function postUpload(Request $request) {
// Change these PHP configurations:
// <?php echo phpinfo() ?\>
// /etc/php/7.2/apache2/php.ini
// upload_max_filesize = 200M
// post_max_size = 210M
// memory_limit = 200M
$this->validate($request, [
'name' => 'max:80'
// 'movie' => 'mimes:mp4,flv,ogg,mov,qt'
]);
$movie = new Movie;
$movie->name = Purifier::clean($request->name);
if($request->hasFile('movie')) {
$file = $request->file('movie');
$filename = $file->getClientOriginalName();
$path = "/var/www/html/wdwsignup/public/.vids/collection/";
return $file->move($path, $filename);
}
$movie->caption = Purifier::clean($request->caption);
$movie->save();
return redirect()->route('admin.videos');
}
Here is the form used to upload:
{{ Form::open(['action' => 'MovieController@postUpload', 'method' => 'post', 'files' => true]) }}
<label>Title:</label><br>
<input type="text" name="name" class="form-control">
<br>
<label>Video:</label><br>
<input type="file" name="movie">
<br>
<label>Caption:</label><br>
<textarea name="caption" cols="30" rows="6" class="form-control"></textarea>
<br>
<input type="submit" name="submit" class="form-control">
{{ Form::close() }}
<br><br>
And it doesn't appear to fulfil the request because my route is:
Route::post('admin/videos/upload', 'MovieController@postUpload')->name('admin.videos.upload');
And the ending URL is '/admin/videos/upload' whereas the resulting URL should have redirected to '/admin/videos' back to the view directory's folder index file.
I do not understand enough about requests so any knowledge is appreciated, thanks.
Please or to participate in this conversation.