Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

PHP error - Image upload

Status
Not open for further replies.
Joined
Jun 1, 2010
Posts
548
Reaction score
2
I've been following a tutorial online to build my own CMS, as a way to learn php code alongside some books I'm reading. Unfortunately the site where the tutorial lives seems to be dead so I can't get any help there (http://www.elated.com/articles/add-image-uploading-to-your-cms/).

I get the following error after I've selected an image to upload and click 'save changes' on the editarticle.php page:

Warning: move_uploaded_file(/images/articles/fullsize/13.jpg): failed to open stream: No such file or directory in E:\xampp\htdocs\test\cms\classes\article.php on line 104

Warning: move_uploaded_file(): Unable to move 'E:\xampp\tmp\phpA387.tmp' to '/images/articles/fullsize/13.jpg' in E:\xampp\htdocs\test\cms\classes\article.php on line 104

Fatal error: Article::storeUploadedImage(): Couldn't move uploaded file. in E:\xampp\htdocs\test\cms\classes\article.php on line 104

Line 104 reads:

if ( !( move_uploaded_file( $tempFilename, $this->getImagePath() ) ) ) trigger_error( "Article::storeUploadedImage(): Couldn't move uploaded file.", E_USER_ERROR );

I appreciate it's a fair amount of code to look through potentially to find the issue, I was just hoping there might be a glaring mistake here that might jump out to someone who knows what they're doing! Cheers
 
Have you made sure that /images/articles/fullsize/ folders all exist? And once they're created ensure they're writeable (0777).
 
Yep all folders exist and paths are correct. I did think it may be a permissions issue, I'm using XAMPP on windows 8. I've made all folders have full permissions for all users (right click, security tab), is that sufficient?
 
Hmm, I've tried creating new files and changing file paths, but it didn't make any difference...

The next line in 'article.php' is an error function to do with permissions and I've never seen that, so it may not be permission related. Similarly, it could just be that the program doesn't get far enough to throw up that error.
 
Set debug points, and see where it stops.

The errors you posted appear to suggest no file was uploaded, or it was unable to write the uploaded data, which in my experience would mean your php interpreter doesn't know where your tmp folder is (which is common on windows machines and less so on *nix) or target folder isn't writable by the user running the script.
 
The tmp folder did cross my mind, I've just checked the config .ini for XAMPP and the path is listed to the correct tmp folder (E:\xampp\tmp), it also has stuff in it. However, nothing matching 'phpA387.tmp' or similar that should be created during this image upload...
 
phpA387.tmp is the temp image file, which is where its put upon upoading, before its renamed and moved.

Have you tried a simple upload script ?
 
I've managed to get it working, I downloaded the full code from the site then piece by piece put my own code back into it... I think the problem was something as spurious as a lowercase in the wrong place (editarticle instead of editArticle) in one instance. Thanks for your help
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom