I've run across a problem where, when open_basedir is enabled in my php.ini, my file uploads don't work in Drupal. The parent directory is included in the open_basedir list, yet uploads still don't work. I've tested this both on my development server (running Windows Server 2008, IIS7 and PHP 5.3.2) and locally on my pc with XAMPP (running Windows 7 Enterprise, Apache 2.2 and PHP 5.3.5). The results are the same: as soon as open_basedir is disabled, file uploads within Drupal work perfectly.

Here's an example of the error I get:

Warning: move_uploaded_file(): open_basedir restriction in effect.
File(public://field/image/example_1.jpg) is not within the allowed path(s):
(K:\content;L:\content;E:\content;E:\Upload_temp) in file_save_upload() 
(line 1528 of E:\content\includes\file.inc).
File upload error. Could not move uploaded file.

This is what my File System settings are:

Public file system path - sites/default/files/pictures

Temporary directory - sites/default/files/pictures/tmp

Directory structure goes like this: E:\content\drupal. As evidenced, Drupal is within the bounds of open_basedir. What am I missing here?

1 Answer 1


The warning appears because public://field/image is not included in the list of directories the open_basedir allows. Links are resolved, but an external path like public://field/image is not resolved to an internal path; for example, if the code is trying to read http://example.com/img_png/image.png and img_png is listen by the open_basedir directive, the warning will be shown.

  • Thanks for your answer kiamlaluno. I initially tried including "public://field/image" in the open_basedir field but it didn't work (as I figured). Following the idea that the public:// address was the root of this problem, I eventually found this thread on Drupal.org: drupal.org/node/1002048. There is a core patch solution provided, and I can confirm that it does work. Obviously, a core patch is not ideal, but until this issue is resolved in a core update, it's the only way to go. May 11, 2011 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.