steve1202 Posted April 6, 2011 Share Posted April 6, 2011 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."; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/ Share on other sites More sharing options...
KevinM1 Posted April 6, 2011 Share Posted April 6, 2011 Use tags to display your code. I put them in for you this time. Quote Link to comment https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/#findComment-1197708 Share on other sites More sharing options...
Pikachu2000 Posted April 6, 2011 Share Posted April 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/#findComment-1197709 Share on other sites More sharing options...
spiderwell Posted April 6, 2011 Share Posted April 6, 2011 the error message is your clue to the problem, its stating that file already exists. echo out the $secure_folder on the line before so you can see what it is. Quote Link to comment https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/#findComment-1197710 Share on other sites More sharing options...
steve1202 Posted April 6, 2011 Author Share Posted April 6, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/#findComment-1197713 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2011 Share Posted April 6, 2011 Why are you trying to create a directory using a URL: <?php mkdir("http://multi-search.org/BSGN/$secure_folder", 0777); ?> The mkdir function takes a path to the directory in the local filesystem. Ken Quote Link to comment https://forums.phpfreaks.com/topic/232862-whats-wrong-with-my-upload-php-script/#findComment-1197719 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.