GetDotted Domains

Viewing Thread:
"PHP sys_get_temp_dir"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Tue 02/11/10 at 18:12
Regular
Posts: 4
sys_get_temp_dir returns /tmp the system wide temporary directory which my php cannot read/write

Is there a function which returns the name of the temporary directory set aside for me - the error message effectively tells me it exists!
Fri 05/11/10 at 20:57
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
Have you tried altering

$this->tmp_dir = '/tmp';

in default_config.php to a folder in your webspace that is writable by your scripts?
If that doesn't work then feel free to send in a ticket to support with details of where the installation is and how to reproduce the problem and they can then forward the query to me to have a look.
Wed 03/11/10 at 17:25
Regular
Posts: 4
I am using VIP hosting.

I have uploaded the PHP ICalendar scripts and was hoping that they would work. I do not think that in this case the sys_get_temp_dir problem is insuperable but it should be fixed.

It could be fixed by creating an environment variable TMP and removing the system wide definition of the function. Users could then successfully use the definition code you posted earlier.
Tue 02/11/10 at 23:07
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
Ah sorry, serves me right for copying and pasting. What are you trying to do exactly? Is there a reason why you can't create a directory in you web space to use a temporary directory?
Is this for your VIP or free hosted site?
Tue 02/11/10 at 19:17
Regular
Posts: 4
Thanks for the speedy reply. It cannot work because the code says make a new function if it does not exist. But it does exist and the answer is /tmp There are no environment variables TMP TMPDIR or TEMP (see phpinfo)

Given that I know the full path name for the temporary directory I want to access how do I code this in php please
Tue 02/11/10 at 18:56
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
Try looking at the comments here and trying

<?php
if ( !function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if( $temp=getenv('TMP') ) return $temp;
if( $temp=getenv('TEMP') ) return $temp;
if( $temp=getenv('TMPDIR') ) return $temp;
$temp=tempnam(__FILE__,'');
if (file_exists($temp)) {
unlink($temp);
return dirname($temp);
}
return null;
}
}

echo realpath(sys_get_temp_dir());
?>


sys_get_temp_dir doesn't work very well in virtual host environments.
Tue 02/11/10 at 18:12
Regular
Posts: 4
sys_get_temp_dir returns /tmp the system wide temporary directory which my php cannot read/write

Is there a function which returns the name of the temporary directory set aside for me - the error message effectively tells me it exists!

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Many thanks!
You were 100% right - great support!
Impressive control panel
I have to say that I'm impressed with the features available having logged on... Loads of info - excellent.
Phil

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.