Laravel - File Input Array Update
I want to update my file input images, but as soon as I update 1 image the other images are removed why is that? I want to left them as what they are when they had been upload. help me please thanks.
Here is an image of the problem
Controller
Update, public function, here is where I put the logic of the code
public function update(Request $request, $id)
{
$this->validate($request, [
'inflightmagz_date' => 'required',
'infightmagazine_pdf.*' => 'image|nullable|max:1999'
]);
$inflightmags = ;
if ($request->has('infightmagazine_pdf'))
{
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
}
$fileNameToStore = serialize($inflightmags);
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf')){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
}
View, edit.blade.php
{!! Form::open(['action'=>['AdminFleetsController@update',$fleet->id], 'method' => 'POST','enctype'=>'multipart/form-data', 'name' => 'add_name', 'id' => 'add_name']) !!}
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<tr>
<td> {{Form::text('title', $fleet->title, ['class' => 'form-control', 'placeholder' => 'Enter a Title', 'id'=>"exampleFormControlFile1"])}}<br>
{{Form::textarea('description', $fleet->description, ['class' => 'form-control', 'placeholder' => 'Enter a Description'])}} <br>
<div class="card card-body col-md-8">
@foreach(explode(' , ' ,$fleet->fleet_image) as $content)
<img src="{{ asset('storage/fleet_images/' . $content) }}" style="width:50px;height:50px;"><br/>
{{ Form::file('fleet_image',['id'=>'exampleFormControlFile1']) }}<br/>
@endforeach
</div>
</td>
</tr>
</table>
{{Form::hidden('_method', 'PUT')}}
{{Form::submit('submit', ['class'=>'btn btn-primary', 'name'=>'submit'])}}
</div>
{!! Form::close() !!}
php arrays laravel laravel-5 eloquent
add a comment |
I want to update my file input images, but as soon as I update 1 image the other images are removed why is that? I want to left them as what they are when they had been upload. help me please thanks.
Here is an image of the problem
Controller
Update, public function, here is where I put the logic of the code
public function update(Request $request, $id)
{
$this->validate($request, [
'inflightmagz_date' => 'required',
'infightmagazine_pdf.*' => 'image|nullable|max:1999'
]);
$inflightmags = ;
if ($request->has('infightmagazine_pdf'))
{
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
}
$fileNameToStore = serialize($inflightmags);
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf')){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
}
View, edit.blade.php
{!! Form::open(['action'=>['AdminFleetsController@update',$fleet->id], 'method' => 'POST','enctype'=>'multipart/form-data', 'name' => 'add_name', 'id' => 'add_name']) !!}
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<tr>
<td> {{Form::text('title', $fleet->title, ['class' => 'form-control', 'placeholder' => 'Enter a Title', 'id'=>"exampleFormControlFile1"])}}<br>
{{Form::textarea('description', $fleet->description, ['class' => 'form-control', 'placeholder' => 'Enter a Description'])}} <br>
<div class="card card-body col-md-8">
@foreach(explode(' , ' ,$fleet->fleet_image) as $content)
<img src="{{ asset('storage/fleet_images/' . $content) }}" style="width:50px;height:50px;"><br/>
{{ Form::file('fleet_image',['id'=>'exampleFormControlFile1']) }}<br/>
@endforeach
</div>
</td>
</tr>
</table>
{{Form::hidden('_method', 'PUT')}}
{{Form::submit('submit', ['class'=>'btn btn-primary', 'name'=>'submit'])}}
</div>
{!! Form::close() !!}
php arrays laravel laravel-5 eloquent
b'cause you upload only one image and another two image empty so its update as empty thats why you two image are update as empty. So for that you need to check if image has empty value than no update and keep its old value at it is.
– Bhargav Chudasama
Nov 26 '18 at 5:26
How can i do that? nice logic sir. how is the syntax? can u pls edit my code sir pls i badly need for this to work
– obito uchiha
Nov 26 '18 at 5:30
checkhasFile
inside for loop
– Bhargav Chudasama
Nov 26 '18 at 5:31
can you please edit my code sir :( so you can let me upvote and marked your answer please :(
– obito uchiha
Nov 26 '18 at 5:32
add a comment |
I want to update my file input images, but as soon as I update 1 image the other images are removed why is that? I want to left them as what they are when they had been upload. help me please thanks.
Here is an image of the problem
Controller
Update, public function, here is where I put the logic of the code
public function update(Request $request, $id)
{
$this->validate($request, [
'inflightmagz_date' => 'required',
'infightmagazine_pdf.*' => 'image|nullable|max:1999'
]);
$inflightmags = ;
if ($request->has('infightmagazine_pdf'))
{
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
}
$fileNameToStore = serialize($inflightmags);
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf')){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
}
View, edit.blade.php
{!! Form::open(['action'=>['AdminFleetsController@update',$fleet->id], 'method' => 'POST','enctype'=>'multipart/form-data', 'name' => 'add_name', 'id' => 'add_name']) !!}
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<tr>
<td> {{Form::text('title', $fleet->title, ['class' => 'form-control', 'placeholder' => 'Enter a Title', 'id'=>"exampleFormControlFile1"])}}<br>
{{Form::textarea('description', $fleet->description, ['class' => 'form-control', 'placeholder' => 'Enter a Description'])}} <br>
<div class="card card-body col-md-8">
@foreach(explode(' , ' ,$fleet->fleet_image) as $content)
<img src="{{ asset('storage/fleet_images/' . $content) }}" style="width:50px;height:50px;"><br/>
{{ Form::file('fleet_image',['id'=>'exampleFormControlFile1']) }}<br/>
@endforeach
</div>
</td>
</tr>
</table>
{{Form::hidden('_method', 'PUT')}}
{{Form::submit('submit', ['class'=>'btn btn-primary', 'name'=>'submit'])}}
</div>
{!! Form::close() !!}
php arrays laravel laravel-5 eloquent
I want to update my file input images, but as soon as I update 1 image the other images are removed why is that? I want to left them as what they are when they had been upload. help me please thanks.
Here is an image of the problem
Controller
Update, public function, here is where I put the logic of the code
public function update(Request $request, $id)
{
$this->validate($request, [
'inflightmagz_date' => 'required',
'infightmagazine_pdf.*' => 'image|nullable|max:1999'
]);
$inflightmags = ;
if ($request->has('infightmagazine_pdf'))
{
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
}
$fileNameToStore = serialize($inflightmags);
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf')){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
}
View, edit.blade.php
{!! Form::open(['action'=>['AdminFleetsController@update',$fleet->id], 'method' => 'POST','enctype'=>'multipart/form-data', 'name' => 'add_name', 'id' => 'add_name']) !!}
<div class="table-responsive">
<table class="table table-bordered" id="dynamic_field">
<tr>
<td> {{Form::text('title', $fleet->title, ['class' => 'form-control', 'placeholder' => 'Enter a Title', 'id'=>"exampleFormControlFile1"])}}<br>
{{Form::textarea('description', $fleet->description, ['class' => 'form-control', 'placeholder' => 'Enter a Description'])}} <br>
<div class="card card-body col-md-8">
@foreach(explode(' , ' ,$fleet->fleet_image) as $content)
<img src="{{ asset('storage/fleet_images/' . $content) }}" style="width:50px;height:50px;"><br/>
{{ Form::file('fleet_image',['id'=>'exampleFormControlFile1']) }}<br/>
@endforeach
</div>
</td>
</tr>
</table>
{{Form::hidden('_method', 'PUT')}}
{{Form::submit('submit', ['class'=>'btn btn-primary', 'name'=>'submit'])}}
</div>
{!! Form::close() !!}
php arrays laravel laravel-5 eloquent
php arrays laravel laravel-5 eloquent
asked Nov 26 '18 at 5:22
obito uchihaobito uchiha
1169
1169
b'cause you upload only one image and another two image empty so its update as empty thats why you two image are update as empty. So for that you need to check if image has empty value than no update and keep its old value at it is.
– Bhargav Chudasama
Nov 26 '18 at 5:26
How can i do that? nice logic sir. how is the syntax? can u pls edit my code sir pls i badly need for this to work
– obito uchiha
Nov 26 '18 at 5:30
checkhasFile
inside for loop
– Bhargav Chudasama
Nov 26 '18 at 5:31
can you please edit my code sir :( so you can let me upvote and marked your answer please :(
– obito uchiha
Nov 26 '18 at 5:32
add a comment |
b'cause you upload only one image and another two image empty so its update as empty thats why you two image are update as empty. So for that you need to check if image has empty value than no update and keep its old value at it is.
– Bhargav Chudasama
Nov 26 '18 at 5:26
How can i do that? nice logic sir. how is the syntax? can u pls edit my code sir pls i badly need for this to work
– obito uchiha
Nov 26 '18 at 5:30
checkhasFile
inside for loop
– Bhargav Chudasama
Nov 26 '18 at 5:31
can you please edit my code sir :( so you can let me upvote and marked your answer please :(
– obito uchiha
Nov 26 '18 at 5:32
b'cause you upload only one image and another two image empty so its update as empty thats why you two image are update as empty. So for that you need to check if image has empty value than no update and keep its old value at it is.
– Bhargav Chudasama
Nov 26 '18 at 5:26
b'cause you upload only one image and another two image empty so its update as empty thats why you two image are update as empty. So for that you need to check if image has empty value than no update and keep its old value at it is.
– Bhargav Chudasama
Nov 26 '18 at 5:26
How can i do that? nice logic sir. how is the syntax? can u pls edit my code sir pls i badly need for this to work
– obito uchiha
Nov 26 '18 at 5:30
How can i do that? nice logic sir. how is the syntax? can u pls edit my code sir pls i badly need for this to work
– obito uchiha
Nov 26 '18 at 5:30
check
hasFile
inside for loop– Bhargav Chudasama
Nov 26 '18 at 5:31
check
hasFile
inside for loop– Bhargav Chudasama
Nov 26 '18 at 5:31
can you please edit my code sir :( so you can let me upvote and marked your answer please :(
– obito uchiha
Nov 26 '18 at 5:32
can you please edit my code sir :( so you can let me upvote and marked your answer please :(
– obito uchiha
Nov 26 '18 at 5:32
add a comment |
1 Answer
1
active
oldest
votes
try this code
add if condition like if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight))
this
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
if ($file->has('infightmagazine_pdf'))
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
$fileNameToStore = serialize($inflightmags);
}
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight)){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
print your$fileNameToStore
array outside thefor loop
and see what was the result
– Bhargav Chudasama
Nov 26 '18 at 5:39
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
|
show 16 more comments
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',
autoActivateHeartbeat: false,
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
});
}
});
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%2f53475133%2flaravel-file-input-array-update%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
try this code
add if condition like if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight))
this
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
if ($file->has('infightmagazine_pdf'))
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
$fileNameToStore = serialize($inflightmags);
}
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight)){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
print your$fileNameToStore
array outside thefor loop
and see what was the result
– Bhargav Chudasama
Nov 26 '18 at 5:39
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
|
show 16 more comments
try this code
add if condition like if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight))
this
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
if ($file->has('infightmagazine_pdf'))
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
$fileNameToStore = serialize($inflightmags);
}
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight)){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
print your$fileNameToStore
array outside thefor loop
and see what was the result
– Bhargav Chudasama
Nov 26 '18 at 5:39
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
|
show 16 more comments
try this code
add if condition like if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight))
this
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
if ($file->has('infightmagazine_pdf'))
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
$fileNameToStore = serialize($inflightmags);
}
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight)){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
try this code
add if condition like if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight))
this
//Handle File Upload
foreach ($request->file('infightmagazine_pdf') as $key => $file)
{
if ($file->has('infightmagazine_pdf'))
{
// Get FileName
$filenameWithExt = $file->getClientOriginalName();
//Get just filename
$filename = pathinfo( $filenameWithExt, PATHINFO_FILENAME);
//Get just extension
$extension = $file->getClientOriginalExtension();
//Filename to Store
$fileNameToStore = $filename.'_'.time().'.'.$extension;
//Upload Image
$path = $file->storeAs('public/infightmagazine_pdfs',$fileNameToStore);
array_push($inflightmags, $fileNameToStore);
$fileNameToStore = serialize($inflightmags);
}
}
$inflightmagContent = InflightMagazine::find($id);
$inflightmagContent->inflightmagz_date = $request->input('inflightmagz_date');
foreach ($inflightmags as $key => $value) {
$implodedInflight = implode(' , ', $inflightmags);
if($request->hasFile('infightmagazine_pdf') && !empty($implodedInflight) && isset($implodedInflight)){
$inflightmagContent->infightmagazine_pdf = $implodedInflight;
}
}
$inflightmagContent->save();
return redirect('/admin/airlineplus/inflightmagazines')->with('success', 'Content Updated');
edited Nov 26 '18 at 6:13
answered Nov 26 '18 at 5:33
Bhargav ChudasamaBhargav Chudasama
4,3582925
4,3582925
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
print your$fileNameToStore
array outside thefor loop
and see what was the result
– Bhargav Chudasama
Nov 26 '18 at 5:39
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
|
show 16 more comments
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
print your$fileNameToStore
array outside thefor loop
and see what was the result
– Bhargav Chudasama
Nov 26 '18 at 5:39
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
still the same sir :( it does not work :( i insert two images and when i update it removed the other image :(
– obito uchiha
Nov 26 '18 at 5:38
print your
$fileNameToStore
array outside the for loop
and see what was the result– Bhargav Chudasama
Nov 26 '18 at 5:39
print your
$fileNameToStore
array outside the for loop
and see what was the result– Bhargav Chudasama
Nov 26 '18 at 5:39
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
wait . it throws an error saying .. Method IlluminateHttpUploadedFile::has does not exist.
– obito uchiha
Nov 26 '18 at 5:40
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
hehe sorry i dont know the syntax for print pls tell me :)
– obito uchiha
Nov 26 '18 at 5:42
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
echo "<pre>;print_r(array);"
– Bhargav Chudasama
Nov 26 '18 at 5:43
|
show 16 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53475133%2flaravel-file-input-array-update%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
b'cause you upload only one image and another two image empty so its update as empty thats why you two image are update as empty. So for that you need to check if image has empty value than no update and keep its old value at it is.
– Bhargav Chudasama
Nov 26 '18 at 5:26
How can i do that? nice logic sir. how is the syntax? can u pls edit my code sir pls i badly need for this to work
– obito uchiha
Nov 26 '18 at 5:30
check
hasFile
inside for loop– Bhargav Chudasama
Nov 26 '18 at 5:31
can you please edit my code sir :( so you can let me upvote and marked your answer please :(
– obito uchiha
Nov 26 '18 at 5:32