almightyegg Posted November 4, 2006 Share Posted November 4, 2006 this is my upload script:[code=php:0]<?if(!$step){?><form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change"><input type="file" name="uploadedfile"><input type="hidden" name="MAX_FILE_SIZE" value="100000"><input type="submit" name="Submit" value="Upload Image" /></p></form><br><?}elseif($step=="change"){$target = "http://www.lordoftheabyss.com/images/players/$mem[id]/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";} else {echo "Sorry, there was a problem uploading your file.";}}?>[/code]i browse for the file and click upload and then it says 'Sorry, there was a problem uploading your file.' and i have no idea why...i cant spot anything wrong ??? Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/ Share on other sites More sharing options...
Zane Posted November 4, 2006 Share Posted November 4, 2006 it's because your giving move_uploaded_file a link destination instead of a pathyou need something like$target = $_SERVER['DOCUMENT_ROOT'] . "/images/players/$mem[id]";$targer .= $_FILES['uploaded']['name']; Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119699 Share on other sites More sharing options...
almightyegg Posted November 4, 2006 Author Share Posted November 4, 2006 the page the uploader is on is: url.com/account/uploader.php and the directories to upload to is url.com/images/player/playeridso it doesnt recognise the path???[code=php:0]$target = $_SERVER['DOCUMENT_ROOT'] . "/images/players/$mem[id]";$target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } [/code] Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119706 Share on other sites More sharing options...
Zane Posted November 4, 2006 Share Posted November 4, 2006 didn't realize you're uploader.php was in a different dir than where the images were goinginstead of document rootyou just need two dots$target = "../images/players/$mem[id]"; Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119709 Share on other sites More sharing options...
almightyegg Posted November 4, 2006 Author Share Posted November 4, 2006 still says it couldnt upload my file :([code=php:0]<?if(!$step){?><form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change"><input type="file" name="uploadedfile"><input type="submit" name="Submit" value="Upload Image" /></p></form><br><?}elseif($step=="change"){$target = "../images/players/$mem[id]";$target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119713 Share on other sites More sharing options...
Zane Posted November 4, 2006 Share Posted November 4, 2006 put this at the very top of your scripterror_reporting(E_ALL);and show me the results Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119716 Share on other sites More sharing options...
almightyegg Posted November 4, 2006 Author Share Posted November 4, 2006 [code=php:0]if(!$step){?><form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change"><input type="file" name="uploadedfile"><input type="submit" name="Submit" value="Upload Image" /></p></form><br><?}elseif($step=="change"){$target = "../images/players/$mem[id]";$target = $target . basename( $_FILES['uploaded']['name']) ; //line 104 $ok=1; if ($uploaded_size > 350000) //line 106{ echo "Your file is too large.<br>"; $ok=0; } if ($uploaded_type =="text/php") //line 112{ echo "No PHP files<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) //line 126 { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } }?>[/code]Notice: Undefined index: uploaded in /home/lordofth/public_html/account/uploadweb.php on line 104Notice: Undefined variable: uploaded_size in /home/lordofth/public_html/account/uploadweb.php on line 106Notice: Undefined variable: uploaded_type in /home/lordofth/public_html/account/uploadweb.php on line 112Notice: Undefined index: uploaded in /home/lordofth/public_html/account/uploadweb.php on line 126 Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119719 Share on other sites More sharing options...
Zane Posted November 4, 2006 Share Posted November 4, 2006 instead of saying$_FILES['uploaded']you need$_FILES['uploadedfile']also it wouldn't hurt to change the $step variable to $_GET['step'] too Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119728 Share on other sites More sharing options...
almightyegg Posted November 4, 2006 Author Share Posted November 4, 2006 Warning: move_uploaded_file(../images/players/1/plasma.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/lordofth/public_html/account/uploadweb.php on line 126Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpmKpwOX' to '../images/players/1/plasma.jpg' in /home/lordofth/public_html/account/uploadweb.php on line 126Sorry, there was a problem uploading your file. is that a CHMOD thing? Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119731 Share on other sites More sharing options...
Zane Posted November 4, 2006 Share Posted November 4, 2006 yeah....try setting the players directory to 0774or 0775 if that doesn't workI'm not a permissions expert but that should workIf your wondering how to change the permissionsyou can either make a temporary php file that says thisif(chmod("../images/", 0774) echo "success";else echo "failed";or change it in the File Manager or Explorer....depending on what OS your using Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119733 Share on other sites More sharing options...
almightyegg Posted November 4, 2006 Author Share Posted November 4, 2006 i can chnage directly from my ftp program but it didnt work anyway :( still displays same problem :( Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119734 Share on other sites More sharing options...
almightyegg Posted November 5, 2006 Author Share Posted November 5, 2006 anybody have anyideas??CHMOD setting is drwxrwxr-- AKA chmod 774 yet access is still denied :-[ Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119891 Share on other sites More sharing options...
Zane Posted November 5, 2006 Share Posted November 5, 2006 have you tried 775?777 will definitely work but it would leave your dir wide open Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119922 Share on other sites More sharing options...
almightyegg Posted November 5, 2006 Author Share Posted November 5, 2006 wtf! it worked but yesterday i set it to that and it didnt ??? o well...thanks :) it doesnt matter that it is open it is my members webspace :D Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119923 Share on other sites More sharing options...
almightyegg Posted November 5, 2006 Author Share Posted November 5, 2006 o wait i was reading a different chmod problem (which is now fixed) so this one isnt fixed :(errors-Warning: move_uploaded_file(../images/players/1/plasma.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/lordofth/public_html/account/uploadweb.php on line 125Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phphgU6A2' to '../images/players/1/plasma.jpg' in /home/lordofth/public_html/account/uploadweb.php on line 125Sorry, there was a problem uploading your file. [code]<?if(!$step){?><form enctype="multipart/form-data" name="form1" method="post" action="uploadweb.php?step=change"><input type="file" name="uploadedfile"><input type="submit" name="Submit" value="Upload Image" /></p></form><br><?}elseif($step=="change"){$target = "../images/players/$mem[id]/";$target = $target . basename( $_FILES['uploadedfile']['name']) ; $ok=1; if ($uploadedfile_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } if ($uploadedfile_type =="text/php") { echo "No PHP files<br>"; $ok=0; } if ($ok==0) { Echo "Sorry your file was not uploaded"; } else { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119925 Share on other sites More sharing options...
almightyegg Posted November 5, 2006 Author Share Posted November 5, 2006 ooh wait...it now uploads to url/images/players/1 but not url/images/players/21maybe because file one has CHMOD 777 and file 21 has CHMOD 755 but it wont let me change file 21 for some reason...so my next question is how do you mkdir() and chmod the file hen makiing it? Quote Link to comment https://forums.phpfreaks.com/topic/26175-help-with-this-code/#findComment-119933 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.