Forum Moderators: coopster

Message Too Old, No Replies

Getting UPLOAD TMP DIR's value.

Or checking a temporary file's MIMETYPE

         

adni18

12:46 am on Sep 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all :)

I have a photo gallery script that I am making, and basically what I need to do is to _either_:

a) Be able to get the value of PHP's UPLOAD_TMP_DIR variable, for getting a temporarily uploaded file (not yet moved to the dest. dir) to check its MIMEtype from there

b) Retrieve the MIMEtype of an uploaded file (not yet moved to dest. dir) without having to know the temporary directory path.

Essentially they're the same thing, although the latter is less likely to be possible with a built-in function.

Got any ideas?

Thanks! :)

coopster

2:27 am on Sep 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you read through Handling file uploads [php.net] yet? Pay particular attention to the directives mentioned throughout the manual pages.

adni18

2:32 am on Sep 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I read through that.

The real issue is going to be figuring out what the actual mimetype of the file is, and not just the file extension.

jatar_k

3:53 pm on Sep 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try one of these

getimagesize [php.net]
exif_imagetype [php.net]

adni18

6:32 pm on Sep 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But to do that you would need to know its filename, no?

I need to determine what kind of mimetype the file is before moving it to a working directory, which is why I need to know the tmp_folder value.

coopster

6:55 pm on Sep 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Again, the information you are asking for is described in the link earlier. Other ideas to consider here as well ...
how would you test if a jpg was uploaded? [webmasterworld.com]
PHP Peer Code Review [webmasterworld.com]