Web Hosting Talk







View Full Version : Possible to create a temp DIRECTORY with php?


mrzippy
04-16-2006, 06:38 PM
Hello,

I have a script that needs to unzip a .zip file into a temp folder. The problem is that it's very difficult to ask the user to create their own temp folder after uploading the script, give it 777 permissions, and then we run into problems if they are running safe_mode, etc. (Because the unzipper can only create one level of folders under the 777 folder before it runs into permissions problems to create additional folder levels...)

I know there is a way to create a temp FILE... but...

... is there any way to create a FOLDER in the temp area for php? And then I could simply unzip the file into that temp folder and kill it when the script is done?

Is it reliable? ie: It has to work on every server, including php4, php5, unix, linux, and windows...

Thanks for any advice!

arkin
04-16-2006, 08:16 PM
Hey mrzippy,

Been a while since I've replyed to you.

Can I get some more information about what your trying to do?

Whats in the .zip file, a script?

mrzippy
04-16-2006, 08:52 PM
Hey mrzippy,

Been a while since I've replyed to you.

Can I get some more information about what your trying to do?

Whats in the .zip file, a script?
I'm trying to basically just unzip a file that has lots of nested folders.... using php safe_mode.

So I have already created a temp folder with the FTP user (owned by the ftp user) and given it 777. Then the .zip flie is dropped into this temp folder, and the script (run as "nobody") tries to unzip the file.

That's where the problem happens.. because the "nobody" user is not able to create nested folders when running in php safe_mode. It can only create ONE level down.. and that's it. Anything else gets a "permission denied" error.

So what I'd like to try and do.. is unzip the file to some "trusted" location on the server, and then I can work with it there. (I need to ftp the unzipped files (including directory structure" to another server.)

Burhan
04-17-2006, 02:44 AM
Why don't you just create a subfolder under /tmp ? That is what its there for :)

bsaint
04-17-2006, 10:56 AM
HIt has to work on every server, including php4, php5, unix, linux, and windows...

Why don't you just create a subfolder under /tmp ? That is what
its there for :)

/tmp on Windows?

Azavia
04-17-2006, 11:01 AM
/tmp on Windows?

Windows has a temporary directory too, just not in the same location as on Linux. :)