Zen Cart Logo
Forums / General Questions / Image Upload Error - permission denied

Image Upload Error - permission denied

Locked

Views: 6,154

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
19 Jul 2006, 10:35 PM
#1
quantum avatar

quantum

Zen Follower

Join Date:
May 2005
Posts:
134
Plugin Contributions:
0

Image Upload Error - permission denied

Hello,

I am getting the error below when I am trying to upload an image for a new product.

Warning: move_uploaded_file(D:/inetpub/website/perfume/images/bw.jpg): failed to open stream: Permission denied in D:\inetpub\website\perfume\admin\includes\classes\upload.php on line 112

Warning: move_uploaded_file(): Unable to move 'C:\PHP\uploadtemp\php17CD.tmp' to 'D:/inetpub/website/perfume/images/bw.jpg' in D:\inetpub\website\perfume\admin\includes\classes\upload.php on line 112

I read through other posts and the common answer was "CHMOD your permissions to 777". I am on a windows server so the process is slightly different, but I have set the permissions to read, write and execute for the whole admin directory and it still doesn't work. I even tried uninstalling and reinstalling the whole cart, same result.

I am using the most up-to-date version of zen-cart by the way.

***Additonal note since posting: I applied read, write and execute to the entire cart, and the uplaod works now. By having this applied to the entire cart, is the cart at risk in anyway?

20 Jul 2006, 7:40 AM
#2
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Image Upload Error - permission denied

Is php.ini set for the upload directory?
Can you use this function in general? Or is it just here that you are getting the error

20 Jul 2006, 8:00 AM
#3
quantum avatar

quantum

Zen Follower

Join Date:
May 2005
Posts:
134
Plugin Contributions:
0

Re: Image Upload Error - permission denied

Hey superprg,

Thanks for the reply. When you say is php.ini set for the directory, how do I check that?

I am also working on another shopping cart with the same host and having the same problem.

The first one I mentoined works fine now because I gave 777 permissions throughout the entire cart.

The second only has these permissions applied to the:

  • includes folder in the admin directory
  • includes folder in the main directory.
  • cache folder in the main directory.

I haven't sent the permissions to 777 for sub folders below those.

I tried uploading an image to the main category section, and while I didn't get an error, it also didn't upload the image.

20 Jul 2006, 10:48 AM
#4
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Image Upload Error - permission denied

quantum:

Hey superprg,

Thanks for the reply. When you say is php.ini set for the directory, how do I check that?

I am also working on another shopping cart with the same host and having the same problem.

The first one I mentoined works fine now because I gave 777 permissions throughout the entire cart.

The second only has these permissions applied to the:

  • includes folder in the admin directory
  • includes folder in the main directory.
  • cache folder in the main directory.

I haven't sent the permissions to 777 for sub folders below those.

I tried uploading an image to the main category section, and while I didn't get an error, it also didn't upload the image.

What is the value of upload_tmp_dir in php.ini?

20 Jul 2006, 11:18 AM
#5
quantum avatar

quantum

Zen Follower

Join Date:
May 2005
Posts:
134
Plugin Contributions:
0

Re: Image Upload Error - permission denied

Hi,

I worked out what php.ini is and ran it:

upload_tmp_dir - C:\PHP\uploadtemp

Is this the info you are looking for?

20 Jul 2006, 5:25 PM
#6
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Image Upload Error - permission denied

quantum:

Hi,

I worked out what php.ini is and ran it:

upload_tmp_dir - C:\PHP\uploadtemp

Is this the info you are looking for?
Yes,
Is permission for this file 777?

Also, please run the function move_uploaded_file seperately and see if it runs properly

21 Jul 2006, 2:24 AM
#7
quantum avatar

quantum

Zen Follower

Join Date:
May 2005
Posts:
134
Plugin Contributions:
0

Re: Image Upload Error - permission denied

Hello,

I don't have access to C:\PHP\uploadtemp to check the permissions.

To run function move_uploaded_file, do I need to install something else? I searched on this in the cart and it only appears as some code in the upload.php file (which doesn't run on its own) and not anywhere else.

Also, if applying 777 permissions to the whole cart folder fixes the problem, wouldn't it likely be that it is a permissions problem within the cart folder and not with the server?

21 Jul 2006, 2:36 AM
#8
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Image Upload Error - permission denied

You dont have to install anything to test move_upload_file

Try this

my.html

<form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form>

uploader.php:

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}

21 Jul 2006, 2:47 AM
#9
quantum avatar

quantum

Zen Follower

Join Date:
May 2005
Posts:
134
Plugin Contributions:
0

Re: Image Upload Error - permission denied

I get the following error message: "There was an error uploading the file, please try again!"

21 Jul 2006, 4:43 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Image Upload Error - permission denied

quantum:

I have set the permissions to read, write and execute for the whole admin directory and it still doesn't work. I even tried uninstalling and reinstalling the whole cart, same result.

***Additonal note since posting: I applied read, write and execute to the entire cart, and the uplaod works now. By having this applied to the entire cart, is the cart at risk in anyway?
Yes, you are putting yourself at risk.
Only the folders mentioned in the installation screens and the installation docs need to be set to read/write/execute.

Here are some tips on securing your site further:
http://www.zen-cart.com/wiki/index.php/Important_Site_Security_Recommendations

If you're having trouble uploading images via the Admin, then your /images folder and subfolders are the place to look for permissions being set to read/write/execute.
You could also upload them via FTP...

21 Jul 2006, 5:10 AM
#11
quantum avatar

quantum

Zen Follower

Join Date:
May 2005
Posts:
134
Plugin Contributions:
0

Re: Image Upload Error - permission denied

Hi Dr Byte,

Thanks, that fixes my problem! I hadn't applied 777 permissions to the image folder. I have done that and it now works perfectly.

Thanks for your help as well superprg.

25 Nov 2006, 9:36 PM
#12
skunkworx avatar

skunkworx

Zen Follower

Join Date:
Mar 2005
Posts:
96
Plugin Contributions:
0

Re: Image Upload Error - permission denied

superprg:

What is the value of upload_tmp_dir in php.ini?

im looking for a fix for a similar issue.

my php.ini file doesnt havea upload_tmp.......... file in it.

what then?

3 Dec 2006, 5:58 AM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Image Upload Error - permission denied

Speak to your hosting site ... we do not write nor control the settings for your php.ini ... nor the permissions of your directories ...

Either you have control over these or need to get together with your hosting site to get them corrected ...

Zen Cart cannot make these changes for you ... that is why you have control over your own server or you need to speak with your hosting site so that you do have control over your own server ...

13 Dec 2006, 4:38 PM
#14
itsmedsee avatar

itsmedsee

New Zenner

Join Date:
Nov 2005
Posts:
7
Plugin Contributions:
0

Re: Image Upload Error - permission denied

I have tried several installs to get image uploads via admin to work. I even reinstalled a few versions back where I knew it use to work.

So that ruled out something wrong with the newest version.

I uploaded and installed another program PHPWEBTHINGS I had the same image and file upload problem.

I can ftp files fine and I use WS FTP.

I checked and rechecked file permissions and the image folder is set to 777.
I also double checked the host console and changed it to 777 through it also.
It is 777.

I then cleared the error logs completely and did a complete reinstall of zencart.
Verified all folder permissions were correct.

I went and tried to change a demo image into one of my own. No upload and no errors on page.

I checked the host error log after attempting to upload an image.

This is the error i received:

PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0

Thanks in advance.

I searched the forums for 3 days and noticed a lot of people are having the same problems, or very similar. What was the answer?