I need an upload script that will upload multiple files at once. I need to set the file names to be the same everytime. So it renames the files after uploading. I need to upload 5-10 files and have them automatically named 1.gif through 10.gif. I have a couple of scripts that do this fine for one file at a time but I need to do multiple for a slide show.
Thanks-
Heres what I use now. If I could some how use a meta refresh after submitting.
Thanks-
<?php
$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "
http://".$_SERVER['HTTP_H
OST'].dirn
ame($_SERV
ER['PHP_SE
LF']);
$url_this = "
http://".$_SERVER['HTTP_H
OST'].$_SE
RVER['PHP_
SELF'];
$upload_dir = "../images/";
$upload_url = "
http://####";
$message ="";
//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("images")) {
die ("upload_files directory doesn't exist");
}
if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "Invalid File Specified. Ignore if you havent clicked upload yet";
}
print $message;
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_n
ame'];
$file_name = '1.gif';
$file_type = $_FILES['userfile']['type'
];
$file_size = $_FILES['userfile']['size'
];
$result = $_FILES['userfile']['error
'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 500000) {
$message = "The file size is over 500K.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}
$result = move_uploaded_file($temp_n
ame, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</
a><br><img
src=$file_url height=\"210\" width=\"210\">" :
"Somthing is wrong with uploading a file.";
return $message;
}
?>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif}
-->
</style>
<title>Slideshow Upload Page</title><form name="upload" id="upload" ENCTYPE="multipart/form-da
ta" method="post">
<span class="style1">Upload Slideshow Image<br>
</span>
<input type="file" id="userfile" name="userfile"><br>
<input type="submit" name="upload" value="Upload">
</form>
<p class="style2">Click Browse to choose the slideshow file (1.gif) on your computer or office network.</p>
<p class="style2">Click Upload</p>
<p class="style2">The image displayed will be in the slideshow on the front page of lulushoponline </p>
<p class="style2"><a href="collage_upload.php">
Change Collage Picture</a></p>
<p class="style2"><a href="slideshow_upload.php
">Change Slideshow Image</a></p>
<p><span class="style2"><a href="featured_upload.php"
>Change Featured Items</a></span> </p>
Start Free Trial