PHP Upload Script Modification

j.venning

In Runtime
Messages
220
Hi everyone! Have just implemented a new upload script on my website, its in PHP but I would like to make it a bit more advance.

Currently, all files get uploaded to http://www.vee-media.com/upload/ but I would really prefer for each file to get a unique location e.g http://www.vee-media.com/fas09jasf/ . I think that this would be a good idea because all the uploaded files wont stay in the same place.

Also, I would also like to put an upload status bar or window when uploading? Does anyone know how I could achieve this?

Here is the script:

PHP:
<?php 
$target = "upload/"; 
$target = $target . basename( $_FILES['uploaded']['name']) ; 
$ok=1; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
$URL="http://www.vee-media.com/uploaded.html";
header ("Location: $URL");
}


?>

I would be very grateful for any help!

Regards,
AJ.

P.S Hope you had a merry christmas and have a good new year!
 
Well, i am not sure exactly how to do the status bar, but i would imagine it would be utilizing PHP & JavaScript. The user would have to select there internet speed, and then, the PHP Script would find out how big the file it, and pass it on to the javascript so that it can work out how long it would take, based on the File Size, and the Users Connection Speed. I have got a file upload script on my server, and it automatically adds 4 random digits to the front of the file name, so that no files get overwritten. I did not write the script my self, but if you like, i can give you the source. Just reply if you want it!

Oh, and on your website (if it is yours), since it's publicly available, i would advidse you to filter out all files with an extention of .php, because that is a MAJOR Security risk. Do somthing like this:

PHP:
str_replace("php, phps, $filename");



Oh, and this is post number 600 :D YAY!

That will replace the .php extention with .phps (which mean php source)
 
Thanks for your reply samurai! Some very helpful info! Do you have MSN or some other IM / IRC so we could chat?

Cheers,
AJ
 
Back
Top Bottom