PHP Curl Proxy, how to define $_FILES['foo']['name'] -


i'm using curl make php proxy forward multipart form.
form have input type="file".

the proxy receive following data:

array   'foo' =>      array       'name' => string 'wt.jpg' (length=6)       'type' => string 'image/jpeg' (length=10)       'tmp_name' => string '/tmp/phpoivrak' (length=14)       'error' => int 0       'size' => int 7427 

so i'm expecting page @ end receive same array (except tmp_name) right receive this:

'foo' =>    array      'name' => 'phpoivrak'      'type' => 'image/jpeg'      'tmp_name' => '/tmp/php5zhcwy'      'error' => 0      'size' => 7427 

as can see, name tmp_name proxy receiving, original filename lost.

here's php code:

$arrfields = $_post; foreach($_files $k => $file)     $arrfields[$k] = '@' . $file['tmp_name'] . ';type=' . $file['type'];  curl_setopt($ressource, curlopt_postfields, $arrfields); 

ps.: know make new variable, goal here respect variable format, , make usage of proxy transparent possible person that'll use it.

is me or solution rename tmp file in /tmp before resending ? looks bit silly me ...

$arrfields = $_post; foreach($_files $k => $file){     move_uploaded_file($file['tmp_name'], $file['name']);     $arrfields[$k] = '@' . $file['name'] . ';type=' . $file['type']; } curl_setopt($ressource, curlopt_postfields, $arrfields); 

i think shouldn't use tmp file instead store file it's real name somewhere, pass postfields param , after executing remove it. seems easiest way me. curl doesn't care original request, tell , ... send temp file over.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -