php - HTTP PUT Request: Passing Parameters with File -
after numerous various tests uploading files throught http post request, looks http put requests suitable large files +1gb upload.
the below listed simple code have tested http put file upload request works well:
javascript:
var req = createrequest(); req.open("put", "php/fileputload.php"); req.setrequestheader("content-type", "text/plain"); req.onload = function (event) { console.log(event.target.responsetext); } req.send(auploadedfile.file_object); php:
include 'chromephp.php'; require_once 'mysqlconnect.php'; ini_set('max_execution_time', 0); chromephp::log( '$_put :' . print_r($_put)); /* put data comes in on stdin stream */ $putdata = fopen("php://input", "r"); /* open file writing */ $fp = fopen("myputfile.ext", "w"); /* read data 1 kb @ time , write file */ while ($data = fread($putdata, 1024)) fwrite($fp, $data); /* close streams */ fclose($fp); fclose($putdata); however, have difficulties delivering arguments , variables file being uploaded javascript php. example, need deliver upload target folder, new data needs stored, id of uploader, etc..
- is there way combine http put request http post submit arguments?
- what options if wish deliver parameters javascript php along http put file upload?
thank you.
using put also, works when append parameters in query string. i'm looking way this. although, workaround i'm using currently
curl -x put "http://www.my-service.com/myservice?param1=val1" --data @file.txt
Comments
Post a Comment