hi,

i have written a php script for uploading files into linux server. but when i try to run that script i get "UPLOAD_ERR_NO_TMP_DIR ". i even tried to changing upload_tmp_dir directive in php.ini and giving it a path to one of my created folders but it seems nothing is working. can anyone help?

Recommended Answers

All 43 Replies

Have you restarted you apache ?

yes i have done that

Execute a script with phpinfo function. Check if the path in upload_tmp_dir is valid. Also check if you have given permissions for the temp directory.

i have changed the upload_tmp_dir in php.ini to point to a directory created in /usr/local/apache/htdocs/tmp, having owner as nobody and permissions of 0777. altough i hve restarted apache but in phpinfo it is showing upload_tmp_dir as no value

Check for "Loaded Configuration File" in phpinfo and change that file. I think you are changing some other php.ini file !

i am making changes to file php.ini located in /usr/local/lib. i have compiled apache and php s static module

umm.. I have never worked with linux. But you should make changes to that ini file mentioned in "Loaded Configuration File", because its that configuration file that will be used by apache.

another php.ini file is present in /etc. even made changes to that anad restarted apache. no success

What does your phpinfo say about the loaded configuration file ?

its says no value

huh! loaded configuration file says no value ? Now that's strange :S !

the same apache and php if i run as localhost the scripts work fine, but if run from a remote pc then it gives this error

What do you mean by 'remote pc' ?

by remote pc i meant running php scripts in my local pc by giving the IP of the remote machine/name of php script in the url

How will it execute the script in the local system if you give the IP of a remote machine ? :S

all the machines are in network. infact i am running my apache/php in my remote pc.in the url just type
http://IP address/*.php

It will run the php file present in the IP address(host) you have specified and not the one which is in your local system.

ya..my apache/php are running in the host

umm.. have you changed the temp dir path in php.ini file in the host ?

ya i am making changes al the changes in the host system only

:S Well, you have 2 php.ini files and have specified the temp directory in both those files. But still when you see phpinfo, temp directory is empty. :) Can you tellme what php.ini file is being used by apache ?

:S Well, you have 2 php.ini files and have specified the temp directory in both those files. But still when you see phpinfo, temp directory is empty. :) Can you tellme what php.ini file is being used by apache ?

once your php/apache is running you have twoh php.ini files. one in /etc and another in /usr/local/lib. apache takes into consideration php.ini located in /usr/local/lib. i thnk i hv made things clear:icon_question:

I guess you have. But then, why is upload temp directory 'empty' if you have made correct changes to php.ini file ?

;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =
upload_tmp_dir = /tmp

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

***********************************
this is the part of my php.ini file with my changes

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "c:/wamp/tmp"

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Now that's my php.ini file.Look at the complete path and its within double quotes.

i have tried that, nad all different combinations... without much success

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. Setting it using putenv() from within a PHP script will not work. This environment variable can also be used to make sure that other operations are working on uploaded files, as well.

Source: http://alamo.nmsu.edu/computer/references/php_manual_en.html

u mean i sud change my server's defult directory. i dont think you can change the server's default directory from a script because by the time the script is executed the files will alredy be uploaded. is that the soultion...???????????????????

No. Just set another environment variable to the temp directory. I have never worked on linux so I dont know how you can set an environment variable in linux, but in windows its pretty simple.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.