modify upload_tmp_dir for file uploads

Posted on 2005-05-12
Last Modified: 2008-02-01
I would like to move the location of the temporary file upload directory for image uploads.. right now it is pointed at a different partition than the rest of my php application, and moving the files from one partition to another is taking too much time (big files are involved).  

I don't have access to the php.ini file, so i can't modify it there, but i have been told that i can add something to a .htaccess file that will do it for me (override the php.ini file i guess).. what i am looking for is the syntax for the .htaccess file that will let me change the temp upload folder to be pointing at whatever folder i want it to.

I think it is the upload_tmp_dir value in the ini file, but i could be wrong about that.

The way the app works is that users go to a page in the following directory:

They select the files that they want to upload and the files get uploaded via a java applet in the following directory:
(the applet is called from the page in the first mentioned directory)

The java applet gets them uploaded (via normal post data submission) and then call another file in same directory as the applet (/usr/home/xxxxx/public_html/administrator/includes) that processes and moves the files to their final/non-temp location.

Like i said earlier, I need to know how to select which folder is used as the temporary file upload directory.
Question by:Caliguian
    LVL 10

    Accepted Solution


    Although many INI values can be set via your script or maybe htaccess, *upload_tmp_dir* is a system related value that can only be set in your PHP.INI file or via the server config (Apache httpd.conf) or config.ini in many other servers.


    Author Comment

    so i cannot set this value locally?
    LVL 7

    Assisted Solution

    No. Check the ini_set reference, and note that upload_tmp_dir is of type PHP_INI_SYSTEM. All other types can be set in your htaccess files using the php_admin_value Apache directive.


    Table 2. Definition of PHP_INI_* constants

    Constant Value Meaning
    PHP_INI_USER 1 Entry can be set in user scripts
    PHP_INI_PERDIR 2 Entry can be set in php.ini, .htaccess or httpd.conf  
    PHP_INI_SYSTEM 4 Entry can be set in php.ini or httpd.conf  
    PHP_INI_ALL 7 Entry can be set anywhere

    LVL 7

    Expert Comment

    If you really must use your own directory, you could consider uploading with a custom HTTP POST - for example embed your file-being-uploaded in an XML packet. This would require that you customised your Java applet. I wouldn't recommend this course of action though.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now