Re: file uploads problem
| From: | Oscar F | Date: | Tue, 24 Sep 2002 04:56:22 +0000 |
| Subject: | Re: file uploads problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-117373@lists.php.net to get a copy of this message | ||
Try:
$upload = "/path/to/copy/";
$upload_path = "$upload/$file_filename";
if (is_uploaded_file($file)) {
Exec("cp $filename $upload_path");
}
Then you have the file at /path/to/copy/<filename>, and you can do whatever you want with it. (I'm assuming the file field of the form is called "file", and that /path/to/copy/ has permissions set so that PHP can write to it, 777 will work for sure, but I'm not 100% positive which one would be best due to security and stuff.).
HTH. Oscar.-
Jaski wrote:
Hi, (Linux RH 7.1, Apache/1.3.22, PHP 4.0.6). I am trying to write a script to send emails. It needs to support attachments. The point where I am stuck is after the file to be attached gets uploaded to /tmp as /tmp/tempfilename thorough an HTTP POST form. I am not able to open that file directly .. follwing error shows up. Warning: fopen("/tmp/phpOaILXx","rb") - Operation not permitted in /var/www/vhosts/mydomain/httpsdocs/lib/email.inc.php on line 254 I tried to copy this file using move_uploaded_file($userfile, "/place/to/put/uploaded/file"); and here a strange thing happened. The file was successfully copied BUT it had permissions like -rw------ which I interpret as only accessible to root. I tried copy() function instead and it failed. I think I have tried every thing I could think of .. so please HELP :) jaski NP. I am subscribed to the digest version so kindly cc any replies to me as well. Thanks.