Enjoy unlimited access to all forum features for FREE! Optional upgrade available for extra perks.

PHP error - Image upload

Status
Not open for further replies.
Joined
Jun 1, 2010
Posts
552
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?
 
I've made all folders have full permissions for all users (right click, security tab), is that sufficient?

In some cases, I have experienced this same issue. After creating a new directory, file permissions were no longer an issue, but try and save into the directory with issues - even when trying to define permissions via CLI - the issue still exists.
 
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!

Featured Services

Sedo - it.com Premiums

IT.com

Premium Members

AucDom
UKBackorder
Be a Squirrel
Acorn Domains Merch
MariaBuy Marketplace

New Threads

Domain Forum Friends

Other domain-related communities we can recommend.

Our Mods' Businesses

Perfect
Service
Laskos
URL Shortener
*the exceptional businesses of our esteemed moderators
Top Bottom