Uploaded file is not saving to database
up vote
0
down vote
favorite
I have created a form where you can upload video files, but I notice that when uploading it, video takes time to upload depending on the size of the file,so to avoid people staring at a screen for a long time waiting for their video to upload I will send them to a page that says "Your video is processing and will be available when ready".The video is indeed saving to the public app folder and also it saves to my aws3 bucket folder as I requested but I noticed that its not saving the file in the database and I don't know why it by passes the database. I am using laravel, ffmpeg to convert and compress videos and ajax. Can someone help me with this. here is my code below
//this the fileupload.blade.php
<div class="container">
<div class="card">
<div class="card-body">
<form method="POST" action=" route('fileUploadPost') " enctype="multipart/form-data">
@csrf
<div class="form-group">
<input name="file" id="poster" type="file" class="form-control">
<input type="submit" value="Submit" class="btn btn-success">
</div>
</form>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
function validate(formData, jqForm, options)
var form = jqForm[0];
if (!form.file.value)
alert('File not found');
return false;
(function()
$('form').ajaxForm(
uploadProgress: function(event, position, total, percentComplete)
window.location.href = "complete";
,
success: function()
,
complete: function(xhr)
);
)();
</script>
//this is the controller
$request->validate([
'file' => 'required',
]);
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters)
$filters->resize(new FFMpegCoordinateDimension(640, 480));
)
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
return response()->json(['success'=>'You have successfully upload file.']);
}
laravel
|
show 12 more comments
up vote
0
down vote
favorite
I have created a form where you can upload video files, but I notice that when uploading it, video takes time to upload depending on the size of the file,so to avoid people staring at a screen for a long time waiting for their video to upload I will send them to a page that says "Your video is processing and will be available when ready".The video is indeed saving to the public app folder and also it saves to my aws3 bucket folder as I requested but I noticed that its not saving the file in the database and I don't know why it by passes the database. I am using laravel, ffmpeg to convert and compress videos and ajax. Can someone help me with this. here is my code below
//this the fileupload.blade.php
<div class="container">
<div class="card">
<div class="card-body">
<form method="POST" action=" route('fileUploadPost') " enctype="multipart/form-data">
@csrf
<div class="form-group">
<input name="file" id="poster" type="file" class="form-control">
<input type="submit" value="Submit" class="btn btn-success">
</div>
</form>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
function validate(formData, jqForm, options)
var form = jqForm[0];
if (!form.file.value)
alert('File not found');
return false;
(function()
$('form').ajaxForm(
uploadProgress: function(event, position, total, percentComplete)
window.location.href = "complete";
,
success: function()
,
complete: function(xhr)
);
)();
</script>
//this is the controller
$request->validate([
'file' => 'required',
]);
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters)
$filters->resize(new FFMpegCoordinateDimension(640, 480));
)
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
return response()->json(['success'=>'You have successfully upload file.']);
}
laravel
Do you get a response?'You have successfully upload file.'
– adam
Nov 9 at 18:56
1
@JayJay123 Thats progress. Try and get an exception from the logs as suggested.
– adam
Nov 9 at 20:17
1
@JayJay123 find thelaravel.log
file. This should be instorage/logs
.
– adam
Nov 9 at 22:55
1
@JayJay123 Clear the log file, attempt to upload again, then look at the log file. You should have a stack trace. Post some details here from the stack trace such as the exception message. Example:[2018-11-08 15:36:42] local.ERROR: ErrorException: Trying to get property of non-object in C:appUserController.php:106
– adam
Nov 9 at 23:09
1
Not a problem. Glad to help.
– adam
Nov 10 at 18:09
|
show 12 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have created a form where you can upload video files, but I notice that when uploading it, video takes time to upload depending on the size of the file,so to avoid people staring at a screen for a long time waiting for their video to upload I will send them to a page that says "Your video is processing and will be available when ready".The video is indeed saving to the public app folder and also it saves to my aws3 bucket folder as I requested but I noticed that its not saving the file in the database and I don't know why it by passes the database. I am using laravel, ffmpeg to convert and compress videos and ajax. Can someone help me with this. here is my code below
//this the fileupload.blade.php
<div class="container">
<div class="card">
<div class="card-body">
<form method="POST" action=" route('fileUploadPost') " enctype="multipart/form-data">
@csrf
<div class="form-group">
<input name="file" id="poster" type="file" class="form-control">
<input type="submit" value="Submit" class="btn btn-success">
</div>
</form>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
function validate(formData, jqForm, options)
var form = jqForm[0];
if (!form.file.value)
alert('File not found');
return false;
(function()
$('form').ajaxForm(
uploadProgress: function(event, position, total, percentComplete)
window.location.href = "complete";
,
success: function()
,
complete: function(xhr)
);
)();
</script>
//this is the controller
$request->validate([
'file' => 'required',
]);
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters)
$filters->resize(new FFMpegCoordinateDimension(640, 480));
)
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
return response()->json(['success'=>'You have successfully upload file.']);
}
laravel
I have created a form where you can upload video files, but I notice that when uploading it, video takes time to upload depending on the size of the file,so to avoid people staring at a screen for a long time waiting for their video to upload I will send them to a page that says "Your video is processing and will be available when ready".The video is indeed saving to the public app folder and also it saves to my aws3 bucket folder as I requested but I noticed that its not saving the file in the database and I don't know why it by passes the database. I am using laravel, ffmpeg to convert and compress videos and ajax. Can someone help me with this. here is my code below
//this the fileupload.blade.php
<div class="container">
<div class="card">
<div class="card-body">
<form method="POST" action=" route('fileUploadPost') " enctype="multipart/form-data">
@csrf
<div class="form-group">
<input name="file" id="poster" type="file" class="form-control">
<input type="submit" value="Submit" class="btn btn-success">
</div>
</form>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
function validate(formData, jqForm, options)
var form = jqForm[0];
if (!form.file.value)
alert('File not found');
return false;
(function()
$('form').ajaxForm(
uploadProgress: function(event, position, total, percentComplete)
window.location.href = "complete";
,
success: function()
,
complete: function(xhr)
);
)();
</script>
//this is the controller
$request->validate([
'file' => 'required',
]);
$viddy=new Video;
$file = $request->file('file');
$fileName =uniqid().$file->getClientOriginalName();
$request->file->move(public_path('/app'), $fileName);
$name_file=uniqid().'video.mp4';
$ffp=FFMpeg::fromDisk('local')
->open($fileName)
->addFilter(function ($filters)
$filters->resize(new FFMpegCoordinateDimension(640, 480));
)
->export()
->toDisk('s3')
->inFormat(new FFMpegFormatVideoX264('libmp3lame'))
->save($name_file);
$imageName = Storage::disk('s3')->url($name_file);
$viddy->title=$imageName;
$viddy->save();
return response()->json(['success'=>'You have successfully upload file.']);
}
laravel
laravel
edited Nov 9 at 19:48
asked Nov 9 at 18:49
JayJay123
277
277
Do you get a response?'You have successfully upload file.'
– adam
Nov 9 at 18:56
1
@JayJay123 Thats progress. Try and get an exception from the logs as suggested.
– adam
Nov 9 at 20:17
1
@JayJay123 find thelaravel.log
file. This should be instorage/logs
.
– adam
Nov 9 at 22:55
1
@JayJay123 Clear the log file, attempt to upload again, then look at the log file. You should have a stack trace. Post some details here from the stack trace such as the exception message. Example:[2018-11-08 15:36:42] local.ERROR: ErrorException: Trying to get property of non-object in C:appUserController.php:106
– adam
Nov 9 at 23:09
1
Not a problem. Glad to help.
– adam
Nov 10 at 18:09
|
show 12 more comments
Do you get a response?'You have successfully upload file.'
– adam
Nov 9 at 18:56
1
@JayJay123 Thats progress. Try and get an exception from the logs as suggested.
– adam
Nov 9 at 20:17
1
@JayJay123 find thelaravel.log
file. This should be instorage/logs
.
– adam
Nov 9 at 22:55
1
@JayJay123 Clear the log file, attempt to upload again, then look at the log file. You should have a stack trace. Post some details here from the stack trace such as the exception message. Example:[2018-11-08 15:36:42] local.ERROR: ErrorException: Trying to get property of non-object in C:appUserController.php:106
– adam
Nov 9 at 23:09
1
Not a problem. Glad to help.
– adam
Nov 10 at 18:09
Do you get a response?
'You have successfully upload file.'
– adam
Nov 9 at 18:56
Do you get a response?
'You have successfully upload file.'
– adam
Nov 9 at 18:56
1
1
@JayJay123 Thats progress. Try and get an exception from the logs as suggested.
– adam
Nov 9 at 20:17
@JayJay123 Thats progress. Try and get an exception from the logs as suggested.
– adam
Nov 9 at 20:17
1
1
@JayJay123 find the
laravel.log
file. This should be in storage/logs
.– adam
Nov 9 at 22:55
@JayJay123 find the
laravel.log
file. This should be in storage/logs
.– adam
Nov 9 at 22:55
1
1
@JayJay123 Clear the log file, attempt to upload again, then look at the log file. You should have a stack trace. Post some details here from the stack trace such as the exception message. Example:
[2018-11-08 15:36:42] local.ERROR: ErrorException: Trying to get property of non-object in C:appUserController.php:106
– adam
Nov 9 at 23:09
@JayJay123 Clear the log file, attempt to upload again, then look at the log file. You should have a stack trace. Post some details here from the stack trace such as the exception message. Example:
[2018-11-08 15:36:42] local.ERROR: ErrorException: Trying to get property of non-object in C:appUserController.php:106
– adam
Nov 9 at 23:09
1
1
Not a problem. Glad to help.
– adam
Nov 10 at 18:09
Not a problem. Glad to help.
– adam
Nov 10 at 18:09
|
show 12 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231690%2fuploaded-file-is-not-saving-to-database%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you get a response?
'You have successfully upload file.'
– adam
Nov 9 at 18:56
1
@JayJay123 Thats progress. Try and get an exception from the logs as suggested.
– adam
Nov 9 at 20:17
1
@JayJay123 find the
laravel.log
file. This should be instorage/logs
.– adam
Nov 9 at 22:55
1
@JayJay123 Clear the log file, attempt to upload again, then look at the log file. You should have a stack trace. Post some details here from the stack trace such as the exception message. Example:
[2018-11-08 15:36:42] local.ERROR: ErrorException: Trying to get property of non-object in C:appUserController.php:106
– adam
Nov 9 at 23:09
1
Not a problem. Glad to help.
– adam
Nov 10 at 18:09