Melinda
Total Posts: 49
Joined: 2007-08-31
Each time I try to upload an image for a product I get:
Unable to create directory ‘/’. Access forbidden.
The media/upload folder along with all the media folders are 777.
What else needs to be done to upload an image and attach it to a product?
Posted: September 10 2007
| top
brians
Total Posts: 14
Joined: 2007-09-05
just a guess—do you got a OPEN_BASEDIR RESTRICTION IN EFFECT error?
I get the same problem, and I get that error. I’ve asked my hosting co about disabling this, have yet to hear back.
Posted: September 11 2007
| top
| # 1
Melinda
Total Posts: 49
Joined: 2007-08-31
can anyone help please?
Posted: September 12 2007
| top
| # 3
Dan Orsborne
Total Posts: 72
Joined: 2007-09-20
The file upload doesn’t work on Windows. I’m looking into fixing it in my verision but in the meantime you can simply disable it as a required field but going to the eav_attribute table and setting is_required = 0
Signature
http://www.igentics.com
Igentics are Internet Engineers, we like to look at things from a different angle. The end result being a fully integrated system encompassing the whole supply chain from supplier to end user, incorporating all legacy systems and data. This increases profits and reduces cost.
Posted: September 20 2007
| top
| # 4
Melinda
Total Posts: 49
Joined: 2007-08-31
Thanks I will do that.
I have a linux server that it doesn’t work on.
Posted: September 20 2007
| top
| # 5
Dan Orsborne
Total Posts: 72
Joined: 2007-09-20
I think I’ve fixed it..... can someone test and confirm and perhaps it could be included in a quick new release to help everyone else out.
I’ve edited \lib\Varien\File\Uploader.php and changed the function _createDestinationFolder.
The problem was caused by this line:
$newPath.= ( $newPath != DIRECTORY_SEPARATOR ) ? DIRECTORY_SEPARATOR . $directory : $directory;
Which would build the path with a \user\ etc etc structure for Linux. I’ve added a new variable (which could/should go into the core settings but I’ve not done that yet) to say which system you are running the code on and then switched to a different line if it is a Win32 system:
$newPath.= $directory . DIRECTORY_SEPARATOR;
This builds c:\ etc etc.
The complete code to replace is:
private function _createDestinationFolder($destinationFolder)
{
if( !$destinationFolder ) {
return;
}
//Start Edit
$this->_system = “Win32”;
//End Edit
$path = explode(DIRECTORY_SEPARATOR, $destinationFolder);
$newPath = null;
$oldPath = null;
foreach( $path as $key => $directory ) {
//Start Edit
if ($this->_system != “Win32"){
$newPath.= ( $newPath != DIRECTORY_SEPARATOR ) ? DIRECTORY_SEPARATOR . $directory : $directory;
} else {
$newPath.= $directory . DIRECTORY_SEPARATOR;
}
//End Edit
if( is_dir($newPath) ) {
$oldPath = $newPath;
continue;
} else {
if( is_writable($oldPath) ) {
mkdir($newPath, 0777);
} else {
throw new Exception("Unable to create directory ‘{$newPath}’. Access forbidden.");
}
}
$oldPath = $newPath;
}
return $this;
}
Signature
http://www.igentics.com
Igentics are Internet Engineers, we like to look at things from a different angle. The end result being a fully integrated system encompassing the whole supply chain from supplier to end user, incorporating all legacy systems and data. This increases profits and reduces cost.
Posted: September 20 2007
| top
| # 6
Dan Orsborne
Total Posts: 72
Joined: 2007-09-20
Just another thought....
If this solution doesn’t help then you can debug the file path by changing the following lines:
if( is_writable($oldPath) ) {
mkdir($newPath, 0777);
} else {
throw new Exception("Unable to create directory ‘{$newPath}’. Access forbidden.");
}
to
if( is_writable($oldPath) ) {
mkdir($newPath, 0777);
} else {
//throw new Exception("Unable to create directory ‘{$newPath}’. Access forbidden.");
echo $oldPath;
echo $newPath
}
That should help you track down any other problems
Thanks
Signature
http://www.igentics.com
Igentics are Internet Engineers, we like to look at things from a different angle. The end result being a fully integrated system encompassing the whole supply chain from supplier to end user, incorporating all legacy systems and data. This increases profits and reduces cost.
Posted: September 20 2007
| top
| # 7
Melinda
Total Posts: 49
Joined: 2007-08-31
I’m not sure about your quote marks around Win32 but I just tried it and still get the same error.
This is the code I used:
private function _createDestinationFolder ( $destinationFolder ) { if( ! $destinationFolder ) { return; } //Start Edit $this -> _system = "Win32" ; //End Edit $path = explode ( DIRECTORY_SEPARATOR , $destinationFolder ); $newPath = null ; $oldPath = null ; foreach( $path as $key => $directory ) { //Start Edit if ( $this -> _system != "Win32" ) { $newPath .= ( $newPath != DIRECTORY_SEPARATOR ) ? DIRECTORY_SEPARATOR . $directory : $directory ; } else { $newPath .= $directory . DIRECTORY_SEPARATOR ; } //End Edit if( is_dir ( $newPath ) ) { $oldPath = $newPath ; continue; } else { if( is_writable ( $oldPath ) ) { mkdir ( $newPath , 0777 ); } else { throw new Exception ( "Unable to create directory '{$newPath}'. Access forbidden." ); } } $oldPath = $newPath ; } return $this ; }
The error is:
Unable to create directory ‘/’. Access forbidden.
I looked in my logs and now get no errors listed so I don’t know about this.
I’m on a linux server with centos 5, php 5.1.6-12 and mysql 5.0 using plesk 8.2 as an admin.
Posted: September 20 2007
| top
| # 8
Melinda
Total Posts: 49
Joined: 2007-08-31
I tried the debug code you listed and it gives me a totally blank page after trying to upload an image and no view source either.
Posted: September 20 2007
| top
| # 9
Dan Orsborne
Total Posts: 72
Joined: 2007-09-20
This is a Win32 solution to the error “Unable to create directory ‘\C:’. Access forbidden”
If you want to debug the Linux code you will need to echo the lines I mentioned in my susequent post. This will show you where it is trying to create the directory so you can track down the problem.
Thanks
Signature
http://www.igentics.com
Igentics are Internet Engineers, we like to look at things from a different angle. The end result being a fully integrated system encompassing the whole supply chain from supplier to end user, incorporating all legacy systems and data. This increases profits and reduces cost.
Posted: September 20 2007
| top
| # 10
Moshe
Total Posts: 1770
Joined: 2007-08-07
Los Angeles
For Windows users, upload attached file as:
lib / Varien / File / Uploader . php
File Attachments
Signature
- I would love to change the world, but they won’t give me the source code -
Posted: September 20 2007
| top
| # 11
Melinda
Total Posts: 49
Joined: 2007-08-31
If you want to debug the Linux code you will need to echo the lines I mentioned in my susequent post. This will show you where it is trying to create the directory so you can track down the problem.
I already tried the debug and I only get a totally blank page that shows nothing. Maybe I’m not understanding what to do.
Posted: September 20 2007
| top
| # 12
Melinda
Total Posts: 49
Joined: 2007-08-31
Do the images have to be in a certain folder on your harddrive before the upload will work or can you get images from any folders on your harddrive?
Posted: September 20 2007
| top
| # 13
Moshe
Total Posts: 1770
Joined: 2007-08-07
Los Angeles
@Melinda: Location of images on your harddrive doesn’t matter as long as they have readable permission.
Did you try updating Uploader.php file attached above?
Signature
- I would love to change the world, but they won’t give me the source code -
Posted: September 20 2007
| top
| # 14
Melinda
Total Posts: 49
Joined: 2007-08-31
Yes I tried your change but I’m still getting this same error message which is driving me nuts. Now, I’m not getting any error messages in the logs so I cannot figure it out. I may try a new install for php 5.1.6 but has the cgi-bin been put in there from the wiki page because the last download did not have a cgi-bin to follow those instructions?
Thanks!
Posted: September 20 2007
| top
| # 15