Jump to content

unable to upload images


jerseyjoe

Recommended Posts

Running latest version of CC3, no mods.

Attempts to upload a product image return the following error:

Warning: move_uploaded_file(/home/starco/public_html/images/uploads/1141338_KO.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/mydomain/public_html/admin/filemanager/upload.php on line 104

But that line is blank. Here are lines 101 through 107

<p class="pageTitle"><?php echo $lang['admin']['filemanager']['upload_image']; ?></p>

<?php if($_GET["custom"]==1){ ?>

LINE 104 WOULD BE HERE BUT THERE IS NOTHING ON THIS LINE

<form action="<?php echo $GLOBALS['rootRel'];?>admin/filemanager/upload.php" method="post" enctype="multipart/form-data" target="_self">

Suggestions for fix, please?

Link to comment
Share on other sites

Looking at /admin/filemanager/upload.php here, those lines you have quoted are 51-54. Line 104 and 105 is below.

if (move_uploaded_file($_FILES['FCKeditor_File']['tmp_name'], $savefile)) {

  @chmod($savefile, 0644);

Does anyone have a fix for this?

TIA

Link to comment
Share on other sites

  • 6 months later...
Guest bryweb

Looking at /admin/filemanager/upload.php here, those lines you have quoted are 51-54. Line 104 and 105 is below.

if (move_uploaded_file($_FILES['FCKeditor_File']['tmp_name'], $savefile)) {

  @chmod($savefile, 0644);
Does anyone have a fix for this? TIA
I thinks this is an IIS Windows PHP issue with using CHMOD after a file is moved. - This is how to CHMOD in Windows changing the file permissions by calling a batch file from PHP. This works on my Windows 2008 Server, so I imagine it should work on Windows 2003. OK, I am sure there is a cleaner way to do this - and if you have 1000's of files in your image/upload folder you will want to rework this (I plan on it soon) but this worked for me. Create a batch file in "\image\uploads" folder, I called mine "permissions.bat" you can create this file with notepad or any text editor, just make sure it is named "permssions.bat" when you are done (or change how it is called below). the content of the file should be the following;

Hope this helps someone, I sure know I spent hours banging my head trying to figure it out.

NOTE: The permissions.bat file will REPLACE all permissions with the ones you set in the line, not ADD - so be cautious and write down what default permissions of the files = first before running the batch file just incase you need to add them to the batch line because your hosting requires certain permissions to work.

Bryan

echo y| cacls C:\Domains\yourdomain\wwwroot\images\uploads\*.* /g Everyone:C Administrator:F




What it all means;



"echo y|"  answers the batch files command of "Do you want to continue"



"cacls"  is the windows command similar to "chmod"  - you can run it alone from DOS prompt to see your options.



"C:\Domains\yourdomain\wwwroot\images\uploads\*.*" is the physical location of what files you want to change the permissions of,  in my case I am sloppy and just changing all the files each time (*.*) - not efficient but it works



"/g"   grants permssions command



"Everyone:C Administrator:F"  Gives  "Everyone"  "C" change permissions,  and "Administrator" "F" Full permissions.



NOW CHANGE THE  "\admin\filemanager\upload.php"  file as follows.



My cubecart version is 3.0.18 so yours may be slightly different;



My Line 104 & 105 looks like this


	if (move_uploaded_file($_FILES['FCKeditor_File']['tmp_name'], $savefile)) {

		@chmod($savefile, 0644);




I added a line under it to look like this


	if (move_uploaded_file($_FILES['FCKeditor_File']['tmp_name'], $savefile)) {

		@chmod($savefile, 0644);

		exec('C:\Domains\yourdomain\wwwroot\images\uploads\permissions.bat');




Which simply adds the "exec"  execute line to run the batch,  obviously you will need to change the directory info to match up the location of your batch file.



And on line 118, 119 & 120 (After adding the above line)


		if(($size[0] > $config['gdmaxImgSize']) OR ($size[1] > $config['gdmaxImgSize'])){



		@chmod($savefile, 0775);




I added a line under it to look like this


		if(($size[0] > $config['gdmaxImgSize']) OR ($size[1] > $config['gdmaxImgSize'])){



		@chmod($savefile, 0775);

		exec('C:\Domains\yourdomain\wwwroot\images\uploads\permissions.bat');
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...