Firstly I already have a script working which upload 1 file at a time but after browsing the web for hours on advice I was wondering if any of you guys had any idea of a working tutorial or scripts.
I've tried 5 different multiple file upload scripts which either have out of date functions or don't work.
Any ideas would be great below is the code I use for 1 file upload if you know how to convert it to allow multiple file uploads that would be great but all in all any help would be appreciated.
<form method="POST" action="upload-process.php" enctype="multipart/form-data">
<input type="file" name="image1" /><br />
<input type="submit" value="Upload" />
</form>
/////////////////////////////
PHP Page
////////////////////////////
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("uploaded_images/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
header('Refresh: 4; url=admin.php');
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploaded_images/" . $_FILES["file"]["name"]);
echo "Image Uploaded successfuly";
header('Refresh: 4; url=admin.php');
}
}
}
else
{
echo "Invalid file";
}
?>
Thanks
This isn't online yet It is only on my local server.
I've tried 5 different multiple file upload scripts which either have out of date functions or don't work.
Any ideas would be great below is the code I use for 1 file upload if you know how to convert it to allow multiple file uploads that would be great but all in all any help would be appreciated.
<form method="POST" action="upload-process.php" enctype="multipart/form-data">
<input type="file" name="image1" /><br />
<input type="submit" value="Upload" />
</form>
/////////////////////////////
PHP Page
////////////////////////////
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("uploaded_images/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
header('Refresh: 4; url=admin.php');
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"uploaded_images/" . $_FILES["file"]["name"]);
echo "Image Uploaded successfuly";
header('Refresh: 4; url=admin.php');
}
}
}
else
{
echo "Invalid file";
}
?>
Thanks
This isn't online yet It is only on my local server.