Re: upload temp dir in vhost env.

From: Date: Sun, 26 Aug 2007 16:27:39 +0000
Subject: Re: upload temp dir in vhost env.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-261296@lists.php.net to get a copy of this message
Hi, that's not a problem to specify where the uploaded file has to be moved after upload. As you specify for each user a personal directory in the system, you just need to use a function like move_uploaded_file() to move the uploaded file to this directory. Each uploaded file goes to, let's say, /tmp (the directory specified in your php config), and inherits from a unique filename. This filename is contained in the $_FILES array available in the script which handles the upload. So if you have a form containing a file upload field called "file", you can retrieve the filename of the newly uploaded file using: $_FILES['file']['tmp_name'] (if the upload went successfully). You can then simply use: move_uploaded_file( $_FILES['file']['tmp_name'], '/path/to/user/personal/dir'); This will work even if multiple users are uploading a file at the same time, as the $_FILES array will contain the info related to a single user. I hope I've been clear enough... Ludo
Hello again; I have a question about upload temp dir as defined in php.ini; I have been working on a project that has registered users, each having a user space portion of the web site file system. I want them to be able to upload images and such and have the stuff transfered to their own user spaces. With one up load temp dir designated, how do I insure that the uploaded files get to the correct destination? Or, is it possible to designate more than one up load temp dir in php.ini. (that would be the best solution) This situation is not a virtual host environment, but one site that will be using ssl. I am using Apache on unix based host and am aware that php assigns a temp name to files that are uploaded, but if different users are uploading files concurrently, there could be a confusion as to where each file should be transfered to. I do not know where else to look for an answer to this question at present. Any knowledgeable response appreciated. Thanks in advance: Jeff K.


« previous php.general (#261296) next »