my PHP upload fails with an error:6
but I don't know why. I checked all the parameters which are descriped in some stackoverflow posts, but without a soulution.
As you see, I just get an error 6. All the values (TMP_DIR, SYS_TMP_DIR) are set, but it does not work.
The apache user has the permission to access /tmp
on the server.
Is there an issue I have overlooked?
require_once '../libs/firephp-core-0.4.0/lib/FirePHPCore/fb.php';
$tmp = getcwd()."/tmp";
ini_set('open_basedir', $tmp);
ini_set('upload_tmp_dir',$tmp);
ob_start();
fb($_FILES, "FILES");
fb(ini_get('open_basedir'), 'OPEN_BASEDIR');
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
fb($tmp_dir, "TMP_DIR");
fb(sys_get_temp_dir(), "SYS-TMP-DIR");
$uploaddir = getcwd()."/uploads/";
$uploadfile = $uploaddir . basename.basename($_FILES['x0']['name']);
fb($uploadfile, 'FILE PATH');
fb(move_uploaded_file($_FILES['x0']['tmp_name'], $uploadfile), "MOVE RESULT");
The upload_tmp_dir
configuration must be set in the php.ini
file so that it is available before the script is running. When the script starts to run the file is already uploaded (or not in case of an error).
ini_set('upload_tmp_dir',$tmp);
I see that you try to set upload_tmp_dir
but that statement is executed to late. Go to php.ini
and set it there:
upload_tmp_dir = /tmp
The problem seems to be that your temp variable not working correctly. After this file from php http://php.net/manual/de/features.file-upload.errors.php the error says Missing a temporary folder