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.']);
}


enter image description here










share|improve this question























  • 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 in storage/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














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.']);
}


enter image description here










share|improve this question























  • 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 in storage/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












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.']);
}


enter image description here










share|improve this question















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.']);
}


enter image description here







laravel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 the laravel.log file. This should be in storage/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






  • 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 in storage/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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Syphilis

Darth Vader #20