Jump to content


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


Multiple file upload

Recommended Posts

Hi guys, I have a multiple file upload script that doesn't work properly. Its supposed to upload two files to two different directories but it only uploads one! Can someone help me please? The code is below thanx.


//This is the directory where images will be saved
$target1 = "publications1/";
$target2 = "publications2/";
$target1 = $target1 . basename( $_FILES['book_image1']['name']);
$target2 = $target2 . basename( $_FILES['book_image2']['name']);

//This gets all the other information from the form

// Connects to your Database
mysql_connect("localhost", "cle", "pass") or die(mysql_error());
mysql_select_db("ipra") or die(mysql_error());

//Writes the information to the database
mysql_query("INSERT INTO `publications` (title, author, DOP, theme, abstract, book_image1, book_image2, status, category, sub_category, link) VALUES ('$title', '$author', '$DOP', '$theme', '$abstract', '$book_image1', '$book_image2', '$status', '$category', '$sub_category', '$link')");

//Writes the photo to the server
$task1=move_uploaded_file($_FILES['book_image1']['tmp_name'], $target1);
$task2=move_uploaded_file($_FILES['book_image2']['tmp_name'], $target2);
if($task1 && $task2)
{//Tells you if its all ok
echo "The Publication was Uploaded Successfully! <br> ";
else {

//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";


Share this post

Link to post
Share on other sites


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.