Post by Bennett 🚀 on Oct 16, 2009 18:04:37 GMT -8
Okay, so I found a multi-upload PHP script, and I customized it, when I found this new one, though I want to incorporate the old one. Why I want the new one? It assigns the filename a random number between 0000 and 9999. Here is the old code:
And here is the new code, that assigns the random number:
How could I incorporate that code into the first one? I would really not want to start all over..
Thanks!
-TPL
EDIT: Pruned first code from some of the notes.
<?php
echo "<link rel='stylesheet' type='text/css' href='default.css' />";
$path= "upload/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
$path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1];
$path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2];
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
//$HTTP_POST_FILES['ufile']['name'] = file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "<center><img src=\"$path1\" /></center><br />";
echo "<center><form><input type='text' size='60' value='http://erinuki-images.comlu.com/upload/".$HTTP_POST_FILES['ufile']['name'][0]."' /></form></center><p>";
echo "<center><img src=\"$path2\" /></center><br />";
echo "<center><form><input type='text' size='60' value='http://erinuki-images.comlu.com/upload/".$HTTP_POST_FILES['ufile']['name'][1]."' /></form></center><p>";
echo "<center><img src=\"$path3\" /></center><br />";
echo "<center><form><input type='text' size='60' value='http://erinuki-images.comlu.com/upload/".$HTTP_POST_FILES['ufile']['name'][2]."' /></form></center><p>";
$filesize1=$HTTP_POST_FILES['ufile']['size'][0];
$filesize2=$HTTP_POST_FILES['ufile']['size'][1];
$filesize3=$HTTP_POST_FILES['ufile']['size'][2];
if($filesize1 && $filesize2 && $filesize3 != 0)
{
echo "<br /><br /><b><center>You're files have been uploaded.</center></b>";
}
else {
echo "<br /><br /><b><center>ERROR.....</center></b>";
}
if($filesize1==0) {
echo "<center>There're something error in your first file</center>";
echo "<BR />";
}
if($filesize2==0) {
echo "<center>There're something error in your second file</center>";
echo "<BR />";
}
if($filesize3==0) {
echo "<center>There're something error in your third file</center>";
echo "<BR />";
}
?>
And here is the new code, that assigns the random number:
<?php
// Your file name you are uploading
$file_name = $HTTP_POST_FILES['ufile']['name'];
// random 4 digit to add to our file name
// some people use date and time in stead of random digit
$random_digit=rand(0000,9999);
//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables
$new_file_name=$random_digit.$file_name;
//set where you want to store files
//in this example we keep file in folder upload
//$new_file_name = new upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "upload/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";
//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
echo "File Name :".$new_file_name."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
}
else
{
echo "Error";
}
}
?>
How could I incorporate that code into the first one? I would really not want to start all over..
Thanks!
-TPL
EDIT: Pruned first code from some of the notes.