Hi all,
Could someone help me with this?
I need to upload 5 images, and pass these to a function in the same page that uploads them, which then displays a message for the user telling them it has been uploaded. Im not sure how to upload five images and get them submitted and also how to pass these to the function with a button.
Heres a form that submits one file to a seperate page that uploads it. But i want the upload code to be in the same page as this. But if there is a way to upload the images using the upload code on the seperate page and then sending a message back to the form page sayin"bla bla uploaded" that would be good.
Form:
<form enctype="multipart/form-data" action="uploadfiles()" method="POST">
<table width="650" border="0">
<tr>
<td width="66%" class="Form_Details">
<p> </p>
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload:
<input name="uploadedfile" type="file" />
Upload code:
$ref_value = $_COOKIE['user'];
// Where the file is going to be placed
$target_path = "Uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
//Insert database reference with image location
mysql_select_db($database_localhost, $localhost);
$Image_query = "INSERT INTO Images (Ref, Image) VALUES ('$ref_value', '$target_path')";
$Image = mysql_query($Image_query, $localhost) or die(mysql_error());
Hope its understandable. Thanks.