[support] drupal_move_uploaded_file not working for me
Austin Einter
austin.einter at gmail.com
Thu Dec 6 02:26:45 UTC 2012
Hi All
I have a requirement, where 1. Using drupal (7.14) form, uploads a excel
file 2. Read a file name, say resume.doc from excel file 3. Then get the
file resume.doc from local machine and put to a proper directory
I am able to do step 1 and 2 properly. For step 3, I am able to created the
directory with 0775 permission.
To upload the file I am making use of drupal api drupal_move_uploaded_file.
Please note that I can not make use of file_save_upload api, as here I do
not have any form with file field.
Can somebody guide me why drupal_move_uploaded_file is not uploading the
file.
I debugged further , my observations are as below.
function drupal_move_uploaded_file($filename, $uri) {
$result = @move_uploaded_file($filename, $uri);
// PHP's move_uploaded_file() does not properly support streams if
safe_mode
// or open_basedir are enabled so if the move failed, try finding a real
path
// and retry the move operation.
if (!$result)
{
drupal_set_message('move_uploaded_file did not work');
if ($realpath = drupal_realpath($uri))
{
drupal_set_message('calling move_uploaded_file with realpath ' .
$realpath . ' and file ' . $filename);
$result = move_uploaded_file($filename, $realpath);
}
else
{
drupal_set_message('calling move_uploaded_file with uri ' . $uri);
$result = move_uploaded_file($filename, $uri);
}
}
else
{
drupal_set_message('move_uploaded_file did work');
}
return $result;
}
@move_uploaded_file($filename, $uri); did not work.
next it tried to upload with realpath , next line executed was
$result = move_uploaded_file($filename, $realpath);
That also did not work.
Can somebody pls point me whats the issue here...
Thanks in advance..
Austin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20121206/46ac4125/attachment.html
More information about the support
mailing list