Hello,
I'm using the following script to upload an image to my server. It uses the script: fileupload-class.php which can be found here:
http://www.waiheke.co.nz/php/ulimages/
It's working fine except it uses the uploaded file name when placing the file into my web server folder. I would like to change the filename before it is copied to the folder.
I've tried everything to figure out how this is done. I've had no luck. Would someone be able to tell me where in the script I can change the name of the file before it is copied into the folder on my server? (i.e., agent_image_001.gif)
Any help would be greatly appreciated. Gary
<?php
require("fileupload-class.php");
$path = "agent_images/";
$upload_file_name = "userfile";
$acceptable_file_types = "image/gifs";
$default_extension = "gif";
$mode = 1;
if (isset($REQUEST['submitted'])) {
$my_uploader = new uploader($POST['en']);
$my_uploader->max_filesize(20000); // 20 kb
$my_uploader->max_image_size(200, 150); // max_image_size($width, $height)
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
$my_uploader->save_file($path, $mode);
}
// if attempted to overwrite existing file, take a look in the folder to see what's there
if ($my_uploader->error) {
$web='<A HREF="http://www.tnevni.com.com/agent_images/look.php" TARGET="_blank"';
$er="<br><br>";
$er1="<br><br>";
$er2=$er.$er1;
echo $my_uploader->error . "<br>\n\n$er2\n";
}
else {
print "<font size=\"-1\" face=\"Verdana, Arial, Helvetica, sans-serif\">" . "[ " . ($my_uploader->file['name'] . " ] has been uploaded successfully.<br><br></font>");
if(stristr($my_uploader->file['type'], "image")) {
echo "<img src=\"" . $path . $my_uploader->file['name'] . "\"border=\"0\" alt=\"\"><BR>";
}
else {
$fp = fopen($path . $my_uploader->file['name'], "r");
while(!feof($fp)) {
$line = fgets($fp, 255);
echo $line;
}
if ($fp) { fclose($fp); }
}
}
}
?>