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
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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.