ITNC
asked on
PHP Curl POST\Upload File and write in real time.
So currently when I use my script to upload a file to my remote server it copies the file to the desired location after the upload has completed. I need to modify the script to write the file in real time to the destination as it is being uploaded. Here is the remote script that accepts the curl post and writes the file as it currently stands:
<?php
$upload_directory=dirname( __FILE__). '/uploads/ ';
//check if form submitted
if (isset($_POST['upload'])) {
if (!empty($_FILES['my_file'] )) {
//check for image submitted
if ($_FILES['my_file']['error '] > 0) {
// check for error re file
echo "Error: " . $_FILES["my_file"]["error" ] ;
} else {
//move temp file to our server
move_uploaded_file($_FILES ['my_file' ]['tmp_nam e'],
$upload_directory . $_FILES['my_file']['name'] );
echo 'Uploaded File.';
}
} else {
die('File not uploaded.');
// exit script
}
}
?>
My ultimate goal here is to be able to check the file size of the file being uploaded as it is being uploaded from the remote end.
<?php
$upload_directory=dirname(
//check if form submitted
if (isset($_POST['upload'])) {
if (!empty($_FILES['my_file']
//check for image submitted
if ($_FILES['my_file']['error
// check for error re file
echo "Error: " . $_FILES["my_file"]["error"
} else {
//move temp file to our server
move_uploaded_file($_FILES
$upload_directory . $_FILES['my_file']['name']
echo 'Uploaded File.';
}
} else {
die('File not uploaded.');
// exit script
}
}
?>
My ultimate goal here is to be able to check the file size of the file being uploaded as it is being uploaded from the remote end.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
gr8gonzo,
That last link you posted looks promising. I am still looking into it but right now I am having issues grasping how I can get that array of info from the remote end. Do you maybe have an example I could look at?
That last link you posted looks promising. I am still looking into it but right now I am having issues grasping how I can get that array of info from the remote end. Do you maybe have an example I could look at?
ASKER
Also can you provide examples for the second point in your first post about the server extensions?
ASKER
I have decided to try using APC_UPLOAD_PROGRESS. I have installed the extension and enabled the necessary options. I am now trying to throw together a test setup now. If you have any further information on this please feel free to share.
PHP File upload info http://php.net/manual/en/features.file-upload.php
cURL does provide some info about file uploads but I've only used it on the command line. http://php.net/manual/en/book.curl.php