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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.