Answer the question
In order to leave comments, you need to log in
How to load multiple files at once in Laravel and display the name of each?
Hello everyone, I ran into a problem uploading files to the server, actually uploading something, but the name of each file, I don’t even know how to display it ..
CODE:
foreach ($r->file('img_other') as $f) {
$f->move($destinationPath,$f->getClientOriginalName());
Good::where('id', $good->id)->update([
"img1" => $f->getClientOriginalName(), //1 файл
"img2" => $f->getClientOriginalName() // 2 файл
]);
}
$total = count($_FILES['uploaded_file']['name']);
if($total != '0'){
// Loop through each file
for($i=0; $i<$total; $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['uploaded_file']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath){
//Setup our new file path
$newFilePath = $uploaddir . $_FILES['uploaded_file']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
mysql_query("UPDATE `goods` SET `img1`='".$_FILES['uploaded_file']['name'][0]."', `img2`='".$_FILES['uploaded_file']['name'][1]."');
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question