DayDreamer16 Posted July 20, 2010 Share Posted July 20, 2010 I keep getting a php error in line 6, when I try to upload an image with this code. <?php $imagename = $_FILES['image']['name']; copy($_FILES['image']['tmp_name'], "./images/$imagename"); echo "Your image has been uploaded and can be viewed here: <br>"; echo "http://www.yoursite.com/images/$imagename <hr>"; echo "<b>Preview:</b><br><img src='./hostedimages/$imagename'>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/ Share on other sites More sharing options...
TheEvilMonkeyMan Posted July 20, 2010 Share Posted July 20, 2010 Can you please post the error here? Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088522 Share on other sites More sharing options...
DayDreamer16 Posted July 20, 2010 Author Share Posted July 20, 2010 Warning: copy(./upload/header.png) [function.copy]: failed to open stream: No such file or directory in /home/a2818626/public_html/upload/upload.php on line 6 Your image has been uploaded and can be viewed here: http://deathdreamer16.site11.com/upload/header.png or just test it here http://deathdreamer16.site11.com/upload/index.html Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088824 Share on other sites More sharing options...
Pikachu2000 Posted July 20, 2010 Share Posted July 20, 2010 Judging by the error message, there doesn't seem to be an images/ directory in the upload/ directory. Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088831 Share on other sites More sharing options...
DayDreamer16 Posted July 20, 2010 Author Share Posted July 20, 2010 i thought of that right after i posted this. i created the images/ directory in the upload/ directory i tried it but it didn't work. i also tried chmodding it. any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088833 Share on other sites More sharing options...
Pikachu2000 Posted July 20, 2010 Share Posted July 20, 2010 Paste the new error message here. Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088834 Share on other sites More sharing options...
DayDreamer16 Posted July 20, 2010 Author Share Posted July 20, 2010 its the same as above. it says it doesn't exist. Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088842 Share on other sites More sharing options...
TheEvilMonkeyMan Posted July 20, 2010 Share Posted July 20, 2010 You're better off using the proper move_uploaded_file() function for this. $upload_dir = './images/'; move_uploaded_file($_FILES['image']['tmp_name'], $upload_dir . $imagename); Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088867 Share on other sites More sharing options...
DayDreamer16 Posted July 21, 2010 Author Share Posted July 21, 2010 doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088930 Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2010 Share Posted July 21, 2010 The code you posted and the error message you posted don't match. You are using ./images/ in the posted code but the error indicates that the actual code that generated the error is using ./upload/ Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088931 Share on other sites More sharing options...
DayDreamer16 Posted July 21, 2010 Author Share Posted July 21, 2010 i've already arranged everything so that all paths are right. i still get the same error. edit----- i've found an identical script http://www.wizecho.com/nav=scripts&s=ajax_image i might just go with this. Quote Link to comment https://forums.phpfreaks.com/topic/208269-help-plz/#findComment-1088954 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.