Forum Moderators: phranque

Message Too Old, No Replies

Missing Temporary Upload Folder Error! Help!

Webhost has so far been useless with fixing the problem. :(

         

Kaylx

4:58 pm on Mar 13, 2008 (gmt 0)

10+ Year Member



Hi peeps,

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]

coopster

6:52 pm on Mar 13, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You are correct, that directive cannot be set by you and must be handled by your hosting provider (or somebody with access to php.ini or httpd.conf anyway).

I assume you get the error because you are checking the file upload progress and monitoring for errors in your PHP script?

Kaylx

7:28 pm on Mar 13, 2008 (gmt 0)

10+ Year Member



Yeh i do and as far as i know my code ain't wrong (see below).

// 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 />&nbsp;\n";
}
// Some other stuff
// ...
}
}
// Upload form code and some other stuff
// ...
?>

[edited by: Kaylx at 7:32 pm (utc) on Mar. 13, 2008]

coopster

8:27 pm on Mar 13, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's what I was referring to, yes. I'm afraid you are going to have to take this one back to your host. Unfortunately, the direction they have offered is incorrect for the reasons you stated, you cannot control that directive in a per-directory override file (.htaccess).

Kaylx

11:57 am on Mar 14, 2008 (gmt 0)

10+ Year Member



Can you tell me where upload_tmp_dir actually refers to? I mean is it an absolute path or relative? And where by default is it located - in the php directory or somewhere else?

coopster

9:40 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



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>

londrum

9:54 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



can't you just put
ini_set ('upload_tmp_dir', 'C:\full_path_to_upload_directory\');

at the top of your file?

...remembering that you need to include the full path

...and remembering that you need to create the directory yourself first, as php won't create it for you

Kaylx

9:58 pm on Mar 14, 2008 (gmt 0)

10+ Year Member



Thanks for all your help. My webhost is going to move me to one of their newer clusters so hopefully that'll fix the problem. I'll keep you posted.

coopster

10:12 pm on Mar 14, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



londrum, that particular directive cannot be set anywhere else but php.ini or httpd.conf. PHP handles certain directives [php.net] differently.