PHP Curl上传文件,带文件浏览按钮

I want to remote upload my file into a server that accept uploads using curl , but without typing the full file path every time with "@" symbol can i make a browse button to select files then proceed to curl upload

this is my code ::

$post = array("file_box"=>"@/path/to/myfile.jpg");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://remote-site");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
$output = curl_exec($ch);
curl_close($ch);

return $output;

just want to change "@/path/to/myfile.jpg" by browse button which passes it's value to php variable

I want to change this [[ $post = array("file_box"=>"@/path/to/myfile.jpg"); ]]

to something like that

[[ $post = array("file_box"=>"@".$variable_contains_file_path_from_browse_button); ]]

to prevent upload the file to middle server(host this script) in the temp path just from the client to the remote server directly

is there any solutions around this

thanks all for any help.

There are several questions in SO which deals with this

here are some of the links

uploading files using curl

Curl php file upload

And also google search strategy is http://bit.ly/PMUf2b

But still since you are asking for a browse button upload from front end, here is the complete set along with the tutor link

you can follow the tutor here which has both front end and php code

upload using curl Here is the php code

    $request_url = ‘http://www.example.com/test.php’;
    $post_params['name'] = urlencode(’Test User’);
    $post_params['file'] = ‘@’.'demo/testfile.txt’;
    $post_params['submit'] = urlencode(’submit’);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $request_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
    $result = curl_exec($ch);
    curl_close($ch);

here is the html code

<form method=”post” action=”test.php” enctype=”multipart/form-data”>
    <input type=”text” name=”name” value=”Test User” />
    <input type=”file” name=”file” />
    <input type=”submit” name=”submit” value=”submit” />
</form>