1

I would like to upload files to my server using php and xmlhttprequest in POST.

But my /tmp dir is too small, so I created a new tmp folder for upload with 777 access, and I changed the vhost conf file to set upload_tmp_dir to this folder's path.

If i display phpinfo, this folder appears as the upload_tmp_dir.

But when I upload a file, nothing appears in the new tmp folder but I can see this type of file in /tmp : 20140321-165951-Uyxh938AAQEAACcDEeEAAAAC-request_body-uW4YRM

What can I do to get php upload to use the tmp folder I created ?

Thanks a lot for your help

Sylvain
  • 71
  • 1
  • 7
  • Maybe too obvious, but did you restart Apache after the change? – BarryDevSF Mar 21 '14 at 16:26
  • I was going to mention that earlier also @BarryDevSF – Funk Forty Niner Mar 21 '14 at 16:30
  • [`See this answer`](http://stackoverflow.com/a/16091596/) which may help. – Funk Forty Niner Mar 21 '14 at 16:31
  • [`This Q&A`](http://stackoverflow.com/q/3105943/) may also explain it. I quote from the answer given: *"PHP will delete uploaded files when the script exits, unless you've moved/copied the file somewhere else yourself. The upload process isn't a "do it now and come back later to deal with it" system. It's "deal with it now, or it's gone"."* – Funk Forty Niner Mar 21 '14 at 16:35
  • Yes I restarted the apache server. And in my php page I use move_uploaded_file($_FILES["myfile"]["tmp_name"],$sNewPath); – Sylvain Mar 21 '14 at 16:49
  • dont forget that the new dir should have the 755 permission, and the own/group be available to the apache / php ... so you could use chown root:www-data /new_upload_dir/ ? – Miguel Apr 05 '17 at 23:26

1 Answers1

0

to upload your files into tmp folder, your should use this

file_put_contents(sys_get_temp_dir().'/file.txt', 'content');
Vadim
  • 19
  • 3
  • My goal is not to upload content in tmp dir. I'm using an html form to upload file on the server, but the tmp folder is too small on this server, and I'd like to use an other folder as php upload tmp dir, but it does not work. – Sylvain Mar 22 '14 at 23:04
  • maybe your settings wrong or your new **upload_folder** has wrong place try this : **upload_tmp_dir = /root/tmp/upload** **your site location - /root/www/** – Vadim Mar 24 '14 at 13:38