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?
Did you know?Explore Trending and Topic pages for more stories like this.
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
9
Other forums
cyrillic string conversion question
Hello,
First time here...
I would like to know if there is a way to convert a
Random date selection
i want to select random date with time(hour+minutes+sec) where date is specified(10/22/2009) and tim
Problem Dereferencing
With these types and tables:
CREATE TYPE MANAGER AS OBJECT (
MGR_ID INTEGER,
Price in PR
Dear Experts,
Why we have to enter the price in the PR, and why there is no free goods indicato
PHP Directory Listing Not working
Hey Guys,
I need help, I tried a ton of directory listing scripts and they all don't work. Al
How to extract/download content from HTTPS page?
Hello to all the Members of this forum, Im Shoiab, A novice programmer in php.. for my first job I h
PHP login form help (Done Most of It)
Hi i am having a problem, when i try logging in it is always saying "Invalid Login" im not
EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules t
A little help needed passing hidden values to next page
I have a page that has hidden values in a form.
example
Code: <input name='signupID
why isn't this PHP code working ???
it's suppose to find a name on the database.
<?php
$s = $_POST["lname&