Forum Moderators: phranque
First of all i dunno if this should be under php or here (apache) forums so sorry.
Anyway the problem is 7 out of 10 times uploading files via a php script to my webspace fails because of the 'missing temporary upload folder' error. I've been uploading files to my webspace with no problem for like the last year or so. It's only now i'm getting this error and i dunno why. I've asked my webhost to fix it but it's been 6+ days now and they have been useless!
Now like i said it doesn't happen all the time which confuses the hell outta me. To me it looks like their servers aren't configured quite right or something but i dunno. I just seem to go round in circles with my webhost...
I'll try and give you as much detail as possible coz any suggestions to fix the problem would be great!
Here's some info just now:
1) upload_tmp_dir is set to /upload_tmp
-- i've been told by my webhost to change it using a .htaccess file to a folder of my own with chmod 777 but i told them upload_tmp_dir can only be changed through php.ini or httpd.conf. It has an access level of 4 (PHP_INI_SYSTEM) and i checked using the php function ini_get_all() to look. I tried changing it anyway through .htaccess and also ini_set() but with no luck.
2) like i said uploading works sometimes but then doesn't other times.
-- so to me the folder does exists then doesn't randomly...
That's all i can really tell you i'm afraid.
P.S. Is there any way around using the temporary upload folder?
Thanks,
Kaylx
[edited by: Kaylx at 5:02 pm (utc) on Mar. 13, 2008]
// upload.php
<?php
if( $_GET['act'] == 'try' )
{
// initialization code
// ...
foreach( $_FILES["ImageFile"]["error"] as $key => $error )
{
if( $error == UPLOAD_ERR_OK )
{
// Do stuff with uploaded file(s)
// ...
}
else if( $error != UPLOAD_ERR_NO_FILE )
{
$body_text .= "<br /><span class=\"failure\">ERROR(".$error."): <span>Image ".($key+1)." was not uploaded!<br />";
switch($error)
{
case UPLOAD_ERR_INI_SIZE:
$body_text .= "The file exceeds the upload_max_filesize directive in php.ini.<br />Max filesize: ".formatsize(ini_get('upload_max_filesize'));
break;
case UPLOAD_ERR_FORM_SIZE:
$body_text .= "The file exceeds the MAX_FILE_SIZE directive that was specified in the upload form.<br />Max filesize: ".formatsize($_POST['MAX_FILE_SIZE']);
break;
case UPLOAD_ERR_PARTIAL:
$body_text .= "The file was only partially uploaded.";
break;
case UPLOAD_ERR_NO_TMP_DIR:
$body_text .= "Missing temporary upload folder.<br />Specified Folder: ".ini_get('upload_tmp_dir');
break;
case UPLOAD_ERR_CANT_WRITE:
$body_text .= "Failed to write file to disk.";
break;
case UPLOAD_ERR_EXTENSION:
$body_text .= "The file upload was stopped by it's extension.";
break;
default:
break;
}
$body_text .= "</span></span><br /> \n";
}
// Some other stuff
// ...
}
}
// Upload form code and some other stuff
// ...
?> [edited by: Kaylx at 7:32 pm (utc) on Mar. 13, 2008]
Files will, by default be stored in the server's default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini. The server's default directory can be changed by setting the environment variable TMPDIR in the environment in which PHP runs...
Handling file uploads [php.net]
To the best of my knowledge if you specify a value in the directive it must be a full path to the directory.
<edit>
Actually, there are other directory-directives in php.ini and relative paths are allowed so you may be able to use a relative path. I tend to stick to absolute paths for my upload_tmp_dir directive though.
</edit>