TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pirajeeth Srisgandarasa
NA
127
501
Insert 2 Datas with Multiple Image? (Example : Images, Price, Detail)
May 27 2022 4:29 AM
$val){ // File upload path $fileName = basename($_FILES['files']['name'][$key]); $targetFilePath = $targetDir . $fileName; // Check whether file type is valid $fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["files"]["tmp_name"][$key], $targetFilePath)){ // Image db insert sql $insertValuesSQL .= "('".$fileName."', NOW()),"; }else{ $errorUpload .= $_FILES['files']['name'][$key].' | '; } }else{ $errorUploadType .= $_FILES['files']['name'][$key].' | '; } } // Error message $errorUpload = !empty($errorUpload)?'Upload Error: '.trim($errorUpload, ' | '):''; $errorUploadType = !empty($errorUploadType)?'File Type Error: '.trim($errorUploadType, ' | '):''; $errorMsg = !empty($errorUpload)?'
'.$errorUpload.'
'.$errorUploadType:'
'.$errorUploadType; if(!empty($insertValuesSQL)){ $insertValuesSQL = trim($insertValuesSQL, ','); // Insert image file name into database $insert = $db->query("INSERT INTO images (file_name, uploaded_on) VALUES $insertValuesSQL"); // $sql = "INSERT INTO `images`(`id`, `file_name`, `uploaded_on`, `status`) VALUES ('?')"; if($insert) { $statusMsg = "Files are uploaded successfully.".$errorMsg; }else { $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = "Upload failed! ".$errorMsg; } }else{ $statusMsg = 'Please select a file to upload.'; } } ?>
Reply
Answers (
0
)
Setup PIN Opencart
Laravel framework to build custom website