i want send form with input:file for send information and upload some (2 to 10) files. when form submit information send to main host (form:action) and i do some process on data and i want upload sending files to another host without uploading in main host, so i researching and find CURL way to sending this part for one PHP file in other host and uploading files on that host, and i fund 3 way to send files: (i used for function to detect all send files and user $i for indexes and put in array before send)

1: just use real path :


2: use file create :


3: use CurlFile :

new CurlFile(realpath($_FILES['attach']['tmp_name'][$i]),mime_content_type($_FILES['attach']['tmp_name'][$i]),basename($_FILES['attach']['tmp_name'][$i]));

but it is not working and destroy my files to send because i use this code in another server for testing how this works but it is not working

this code is in another server (target of CURL) :

/*uploading files and insert this information to database ...*/

but in all 3 way i said, the extension be "tmp" not real extension of my send files; so how i can fix this ?

WAY 1 :

$PostItems['attachment['.$i.']']=new CurlFile(realpath($_FILES['attachment']['tmp_name'][$i]),mime_content_type($_FILES['attachment']['tmp_name'][$i]),basename($_FILES['attachment']['tmp_name'][$i]));

WAY 2 :


WAY 3 :


echo $result;

i expect in another server (target of curl) i get information from sending files but in all ways the extension of files to be "tmp" and name of files all of them to be "php1234.tmp" and not real my files name

0 Answers