I have been getting this error when trying to upload images with imagecache.

* warning: is_file() [function.is-file]: open_basedir restriction in effect. File(/tmp/php_upload/phpkw3Tds) is not within the allowed path(s): (VIRTUAL_DOCUMENT_ROOT:/usr/local/lib/php:/usr/local/lib/ph:/home/chroot_lib/phplib/:/usr/local/bin/) in /home/0-web/08/cc/wildplanet.com.au/public/www/includes/image.inc on line 117.
* The selected file header_pattern.png could not be uploaded. The file is not a known image format.

I have spent probally a good 5 hours trying to work this out, and going insane! (mostly just looking in every corner of the web for a solution.)

I dont understand what "VIRTUAL_DOCUMENT_ROOT:/usr/local/lib/php:/usr/local/lib/ph:/home/chroot_lib/phplib/:/usr/local/bin/" means...? what directory should i be putting the tmp file in? in previous installations (on my own server) i never had to create this..

---

from ilisys server php info file:
open_basedir VIRTUAL_DOCUMENT_ROOT:/usr/local/lib/php:/usr/local/lib/ph:/home/chroot_lib/phplib/:/usr/local/bin/ no value

from my own server php info file
open_basedir /home/stevo0/:/usr/lib/php:/usr/local/lib/php:/tmp no value

should i get in contact with the new server company.. its a server my client currently pays for. so it needs to be on his server.

---

Ive set all my folder permissions.

Tried different directories. including tmp, /tmp/, tmp/, currently just at the default 'sites/default/files/tmp'

Any help greatly appreciated...? should i go to drupal consultants?

Comments

Hi,

OK, well I can see two things going on here - the first, and easiest to deal with, is that it looks like you need to add the .png extension to your list of allowed image types, but you can do that through the Drupal admin pages.

The other warning you're seeing is because the filepath, where Drupal is trying to upload the file, is not in the allowed file paths set in open_basedir. On your own server the /tmp folder is within the open_basedir list (at the end), but on the client's server it's not included in the list of allowed directories. If you have shell access to the client's server you could modify the vhost configuration to allow uploads to /tmp (but the client may not want you to change that), but the VIRTUAL_DOCUMENT_ROOT entry should mean that you can access any directory as long as it is created within the directory where your vhost resides, so I'm puzzled as to why you can't use 'sites/default/files/tmp' (unless you're doing something clever with multisites). I know you said you've checked the file permissions, but the file is probably being uploaded by the Apache, so make sure the directory is writable for that user.

If that doesn't work, I'd try contacting the hosting company and see what they suggest.

hmm, ive had another look with your comments. (your reply is much appreciated)

i tried applying all the directories as possible upload locations (as allocated by open_basedir)... /usr/local/lib/php, /home/chroot_lib/phplib/, /usr/local/bin/ and had 'writing permissions not enabled - or something alike... (understandable)

The /usr/local/lib/ph didnt exist. unless i added a 'p' at the end... so weather they typed it in or it got copied in incorrect? (got the same writing permissions not enabled error).

I understand where your saying that because the "VIRTUAL_DOCUMENT_ROOT" is there, it should work for my server. All folders are definitely writable (777). That is folders i have access from the vroot.

---

the extension error occurs with jpgs and gifs. so i assumed it was associated with the first error...

---

I may get in contact with the host. But in truth i have no idea how to word my situation or pose my question.. this all seems so overly complex and technical.. o_0

Regards

Stevo

EDIT:

The selected file .jpeg cannot not be uploaded. Only files with the following extensions are allowed: gif, jpg, png.

That happens if i upload a .jpeg, so it should accept gif, jpg, png, assuming first error is fixed.. unless this is a hint, that this is a bigger problem?

Hi,

All the /usr/local/etc folders are storage for PHP libraries and the like. While the Apache and PHP processes need access to those, it's not a good place to store temporary files, so it's probably just as well the file permissions won't let you!

The image-type error may just be a secondary error thrown up by the upload problems, so I'd worry about that when you get the uploads working...

I'd phrase the question to the host quite simply (otherwise you might get an over-technical reply!), and briefly tell them what you have tried already without success. So something like: What is the preferred path for temporary files on server X when working with vHosts? Then mention that you get an open_basedir warning when trying to access the system /tmp folder, and you can't get things working using a directory within the vHost root.

I gave a call to one of the consultants, and he said that he needed to know how the file was being uploaded? ftp? or what script is being used to help upload it? also left an email so they may come back with something else.

is their a directory to where the script is located in drupal?

----

/**
* Get details about an image.
*
* Drupal only supports GIF, JPG and PNG file formats.
*
* @return
* FALSE, if the file could not be found or is not an image. Otherwise, a
* keyed array containing information about the image:
* 'width' - Width in pixels.
* 'height' - Height in pixels.
* 'extension' - Commonly used file extension for the image.
* 'mime_type' - MIME type ('image/jpeg', 'image/gif', 'image/png').
* 'file_size' - File size in bytes.
*/
function image_get_info($file) {
if (!is_file($file)) {
return FALSE;
}

$details = FALSE;
$data = @getimagesize($file);
$file_size = @filesize($file);

if (isset($data) && is_array($data)) {
$extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
$extension = array_key_exists($data[2], $extensions) ? $extensions[$data[2]] : '';
$details = array('width' => $data[0],
'height' => $data[1],
'extension' => $extension,
'file_size' => $file_size,
'mime_type' => $data['mime']);
}

return $details;
}

----

if (!is_file($file)) {

----
Line 117
----

it says that their is an error on line 117. the !is_file is sending the error. saying that the file doesnt exist. I realise we know that already, but just showing that i am looking and trying to fix the solution..

Otherwise, i might try an reinstall again this afternoon...

Any help would be greatly appreciated..... ..

----

I also noticed in the 'Status Report'

----

Upload progress Not enabled
Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the PECL uploadprogress library (preferred) or to install APC.

----

The upload progress doesnt seem to be enabled. this is to do with showing an ajax version of the upload % of a file upload? so i assume this doesnt directly effect the file upload but it could possibly be associated?

just putting all the details down in front?

Regards,

chris

I had a similar situation. I saw the error message appear when I was trying to display GMaps with Locale CCK module and Views. I had developed locally through MAMP and then uploaded via FTP, unzipped through SSH.

Resetting the File System paths and saving the configuration solved the problem.

Hi
Had the same problem- after an hour gave up and rang Ilisys. This this and Ilisys hosting specific issue - by their design.
You have to call their tech department and get them to configure the virtual host's upload_tmp_dir, they will then provide you with a tmp path and you can set that in admin->settings->file system.
Then you wait for it to propagate through their server/mirrors etc and you're away.

Lee

Lee Rowlands

--author="larowlan <larowlan@395439.no-reply.drupal.org>"