michaelnaeseth
New member
I need to have a multiple file upload form on my website that asks the uploader their name and then renames the files they upload to their last name. Here is the code i am currently using:
The form:
*********************************
<html>
<body>
<form enctype="multipart/form-data" action="new_ac.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
****************************
The PHP Code:
*******************************
<?php
$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($uploaded_size > 1000000)
{
echo "Your file is too large. Please re-size your image and retry. (Max file size = 1 MB)<br>";
$ok=0;
}
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
if ($uploaded_type =="text/html")
{
echo "No HTML files<br>";
$ok=0;
}
if ($uploaded_type =="text/htm")
{
echo "No HTM files<br>";
$ok=0;
}
if ($uploaded_type =="text/xml")
{
echo "No XML files<br>";
$ok=0;
}
if ($ok==0)
{
Echo "An error occured during the upload, your file was not uploaded";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
****************************
Please help if you can.
The form:
*********************************
<html>
<body>
<form enctype="multipart/form-data" action="new_ac.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
</body>
</html>
****************************
The PHP Code:
*******************************
<?php
$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($uploaded_size > 1000000)
{
echo "Your file is too large. Please re-size your image and retry. (Max file size = 1 MB)<br>";
$ok=0;
}
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
if ($uploaded_type =="text/html")
{
echo "No HTML files<br>";
$ok=0;
}
if ($uploaded_type =="text/htm")
{
echo "No HTM files<br>";
$ok=0;
}
if ($uploaded_type =="text/xml")
{
echo "No XML files<br>";
$ok=0;
}
if ($ok==0)
{
Echo "An error occured during the upload, your file was not uploaded";
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
****************************
Please help if you can.