Jump to content

Multiple file upload


cle13

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.

[code]<?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.";
}
?>[/code]


Thanx
Link to comment
https://forums.phpfreaks.com/topic/23147-multiple-file-upload/
Share on other sites

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.