PDA

View Full Version : Uploader..



Owen
01-01-2006, 11:24 PM
Right, i can make the basic uploader in php, but i can't get it so if theres 2 files with the same name it will like add a number to one or whatever so you could keep uploading files with the same name without errors.

Anyone know how to do this ;S

Luckyrare
01-01-2006, 11:28 PM
http://uk2.php.net/rand </3

Owen
01-01-2006, 11:30 PM
http://uk2.php.net/rand </3

You could of told me this before :'(

Luckyrare
01-01-2006, 11:43 PM
LYKE OMG! TIS A LEET SITE WWW.PHP.NET K PLS?

Yeah, php.net is a good site... Just search for the function ect and ta da! Samples and tells you how to use the function.

nets
02-01-2006, 01:43 AM
You could of told me this before :'(
Just check the files already in there, and if there is one of the same file name return with an error.

Graphics
02-01-2006, 01:44 AM
<?php
function rand_array($start, $end, $rangemin, $rangemax)
{
$array = array_fill($start, $end, 1);

foreach($array as $key => $value)
{
$value = rand($rangemin,$rangemax);
print "$key: $value<br>\n";
}
}

$start = 1;
$end = 1000;
$rangemin = 1;
$rangemax = 20000;

rand_array($start, $end, $rangemin, $rangemax);
?>

TooShort4
02-01-2006, 01:44 AM
Just instead of using file names, encrypt the filename into a number like 6878486.gif etc

timROGERS
02-01-2006, 09:47 AM
Hmm, Graphics, you don't need that lmao :P

<?php
$rand = rand(1,100000);
$filename = $_POST['file'];
$upload = $file$rand;
?>

That will do the job if you make the upload form called file, and then rename the uploaded file to $upload ;)

Coding4Newbs
02-01-2006, 09:50 AM
Lol @ graphics for trying :),

Like tim omgz i didnt know u knew php :)

Want to hide these adverts? Register an account for free!