Jump to content

What's wrong with my upload php script?


steve1202

Recommended Posts

im getting a warning saying 'Warning: mkdir() [function.mkdir]: File exists in /home/multisea/public_html/BSGN/secure_upload.php on line 5' if i execute the script below

 

<?php
$secure_folder = "upimg/$rand/$time";
$rand=rand(0000000000,9999999999);
$time=time();
mkdir("$secure_folder", 0777);
echo "secure folder made successfully... not done yet so dont close this window...";
$target = "$secure_folder";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($uploaded_size > 1500000) 
{ 
echo "Your file is too large.<br>"; 
$ok=0; 
} 
if ($ok==0)
{
echo "sorry your file was not uploaded...";
}
else
{if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{echo "the file ". basename( $_FILES['uploadedfile']['name']). "hasbeen uploaded the link to your file is http://multi-search.org/BSGN/$secure_folder/". basename( $_FILES['uploaded']['name'])."<br />";
}
else
{echo "sorry, there was a problem uploading your file.";
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/
Share on other sites

You're attempting to use the values of $rand and $time before you've initialized them, therefore they're non-existent. You should be developing with error_reporting set to -1 and display_errors set to on in your php.ini file, so errors like this are reported.

hey i changed the code abit to


<?php
$rand=rand(0000000000,9999999999);
$time=time();
$secure_folder = "upimg/$rand/$time";
mkdir("http://multi-search.org/BSGN/$secure_folder", 0777);
echo "secure folder made successfully... not done yet so dont close this window...";
$target = "$secure_folder";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
if ($uploaded_size > 1500000) 
{ 
echo "Your file is too large.<br>"; 
$ok=0; 
} 
if ($ok==0)
{
echo "sorry your file was not uploaded...";
}
else
{if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{echo "the file ". basename( $_FILES['uploadedfile']['name']). "hasbeen uploaded the link to your file is http://multi-search.org/BSGN/$secure_folder/". basename( $_FILES['uploaded']['name'])."<br />";
}
else
{echo "sorry, there was a problem uploading your file.";
}
}
?>

but its still not working,,, can u c y its not working?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.