michaelnaeseth
New member
I have a upload form in my website, the form includes a field for the uploader to put their last name in. field name="lastname"
Anyway, I would like to know how to rename the file upload to the persons last name and attach a number to the end for multiple uploads, etc. If anyone could help me with this I would be very appreciative.
Here is my current php script if you would like to look at it:
<?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.";
}
}
?>
Anyway, I would like to know how to rename the file upload to the persons last name and attach a number to the end for multiple uploads, etc. If anyone could help me with this I would be very appreciative.
Here is my current php script if you would like to look at it:
<?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.";
}
}
?>