Jump to content

Upload two files at once


Bman900

Recommended Posts

here is my code:

 

<?php $target_path = "videos/";
$imgtarget_path = "image/";
/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$movielink = basename( $_FILES['uploadedfile']['name']);
$imagelink = basename( $_FILES['imagefile']['name']);
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
$imgtarget_path = $imgtarget_path . basename( $_FILES['imagefile']['name']); 

if((move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) || (move_uploaded_file($_FILES['imagefile']['tmp_name'], $imgtarget_path))) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
    echo "The file ".  basename( $_FILES['imagefile']['name']). 
    " has been uploaded";
mysql_query("INSERT INTO video 
(title, descript, link, image) VALUES('$formtitle', '$descrip', '$movielink', '$imagelink') ") 
or die(mysql_error());  

} else{
    echo "There was an error uploading the file, please try again!";
}
?> 

 

The video file gets uploaded correctly but the image file doesn't go any where. It gives me the messages that they both have been uploaded fine which obviously is wrong. Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/163497-upload-two-files-at-once/
Share on other sites

In this line:

 

if((move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) || (move_uploaded_file($_FILES['imagefile']['tmp_name'], $imgtarget_path))) {

 

You're saying if "uploadedfile" OR "imagefile" are uploaded (...) That should be && (AND); although to be honest I wouldn't do it that way. Do you have errors enabled do you know? If there's no warning message that suggests the file you're trying to upload is not valid.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.