Jump to content


Photo

Multiple file upload


  • Please log in to reply
1 reply to this topic

#1 cle13

cle13
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 06 October 2006 - 05:11 AM

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.

<?php 

//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 
$title=$_POST['title'];
$author=$_POST['author'];
$DOP=$_POST['DOP'];
$theme=$_POST['theme'];
$abstract=$_POST['abstract'];
$book_image1=($_FILES['book_image1']['name']);
$book_image2=($_FILES['book_image2']['name']);
$status=$_POST['status'];
$category=$_POST['category'];
$sub_category=$_POST['sub_category'];
$link=$_POST['link'];

// 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> ";
header("location:publist.php"); 
} 
else { 

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


Thanx

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 06 October 2006 - 05:37 AM

Could we see the form?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users