Amend code to allow multiple attachments


Posted on 16th Feb 2014 07:03 pm by admin

Hi

I have a php page that allows the user to browse to a file (image) then sumbit, the confirmation page then has the following code which uploads the said file to the hosting server, but also appends a unique number (WOref) to the file name and saves some other information to a MYSQL database. It also confirms the upload by showing a preview of the image. What I want is to allow at the browse for file stage, for it to select more than one file, and then upload those files using the same principles below. Any ideas?


Extract from Initial page with file browse button and area:

<input type="file" name="photo">



Extract from Confirmation page of the code which uploads file etc:
<?php
//This gets all the other information from the form
$name=$_POST['WOref'];
$pic=($_FILES['photo']['name']);

//This is the directory where images will be saved
$target = "uploads/";
$target = $target .$name. basename( $_FILES['photo']['name']);

mysql_query("INSERT INTO `attachments` VALUES ('$name','$pic','$target',current_timestamp)") ;

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{

//Tells you if its all ok
echo "The file " .$pic. basename($_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {

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

<?php chmod( $target , 0644 );?>

<img src="<?php print $target; ?>">



Many many thanks.

No comments posted yet

Your Answer:

Login to answer
258 Like 9 Dislike
Previous forums Next forums
Other forums

RadioButtonList data selection
view plaincopy to clipboardprint?

Echo multiple lines of html code
Hi guys,

I would like to know if there is a way to echo multiple lines of html codes.

Quick fix: Conditional statement with an array
Hi, I'm getting the temperature value off of the Environment Canada website along with the icon file

progress bar...need expert opinion of experienced webmaster
Hey guys, quick question:

I want to display a progress bar when I upload files, but I am not

noob question
i traying to do a php form with auto replay for both(me and the user who send me a mail),

a u

Preg_match with an array
is there an away to use preg_match with an array?

i want to check a string with an array to s

ALV List Display to point to another report on Double Click
Hi,

I want my ALV List Display to point to another report on Double Click on its line ite

Opening Multiple Files/Links in Order.
I want to open links in order/one-by-one and check each for a specific string.

Example:
I

selection tool on raster image
Hi!
I have to implement in my app a selection tool which lets users to select region of any shape

Undefined index on my form
ok im getting Undefined index on this line.. print_r($_REQUEST['form']);

below is the full sc

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash