I am trying to create a html file in php where in user has to upload data for uploading in Box.net using API. Form tag's action attribute has a url, which sends back an acknowledgement message.
My problem is when i upload a file and click submit,I get an xml response page. But i don't want User to see such data, but i want this data for computation and show user appropriate message.
How can i get that xml response?
Following is my code:
<?php
$upload_url = 'https://upload.box.net/api/1.0/upload/i9g1fmnn9odhg739sdgdfgdg/480416060';
?>
<form action="<?php echo $upload_url;?>"
enctype="multipart/form-data" accept-charset="utf-8" method="POST">
<input type="file" name="new_file1" />
<input type="text" name="share" value="1" />
<input type="submit" name="upload_files" value="Upload File" />
</form>
you can do that
echo $_POST['new_file1']
echo $_POST['share']
echo $_POST['upload_files']
To send your request to Box you'll need to change the form so that it posts to your own PHP file. Then to send the request to box from your server, in the file that you directed the form to submit to you'd do something like the following:
<?php
$ch = curl_init();
$upload_url = 'https://upload.box.net/api/1.0/upload/i9g1fmnn9odhg739sdgdfgdg/480416060';
curl_setopt($ch, CURLOPT_URL, $upload_url);
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
"file_box" => "@" . $_FILES['upload']['tmp_name'],
"share" => $_POST['share']
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
?>
The $response object will contain the response from Box.