![]() start curl set up for remote file uploadĬurl_setopt($curl, CURLOPT_URL, ‘weblink’) Ĭurl_setopt($curl, CURLOPT_RETURNTRANSFER, 1) Ĭurl_setopt($curl, CURLOPT_POSTFIELDS, $remoteData) Įcho $response // set response to server.php fileĮcho “Your file not uploaded to server. ‘userkey’ =>’HAXDxnSG4rA57SjjxHdwxvkNexU9fvH5′ ‘fileData’ => file_get_contents($uploadFile), I don’t have a fix for the base654 endcoding, but here is my full code for those who wants to add security features ‘fileData’ => file_get_contents($uploadFile) Now it works it uploads the complete file, but the server returns no response maybe its because of the base64 encryption so i had to remove it to get a file response as so In this file cURL send file to any web server. Now create a receiver.php file to handle this form post request. This will post data in URL encrypted form. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. Make sure that form use ‘ multipart/form-data ‘ enctype value. cURL is a library that lets you make HTTP requests in PHP. ![]() ‘fileData’ => base64_encode(file_get_contents($uploadFile)) First create a simple HTML form to upload a file. I added ‘file_get_contents’ to the filedata as so Hello i tried your code but some reason it was not uploading the complete file mostly in bytes, i kept me up for over 12 hours i though i should share in case someone else encounters this issue too, in the local.php i transformed the code as so To send file properties in the secure communication protocol, use the curlfilecreate function - for php 5.5+ - instead of the deprecated method. $uploadFile, 'fileData' => base64_encode ( $uploadFile ) ) // start curl set up for remote file uploadĬurl_setopt ( $curl, CURLOPT_TIMEOUT, 30 ) Ĭurl_setopt ( $curl, CURLOPT_POST, 1 ) Ĭurl_setopt ( $curl, CURLOPT_RETURNTRANSFER, 1 ) Ĭurl_setopt ( $curl, CURLOPT_POSTFIELDS, $remoteData ) Įcho $response // set response to server.php file } else ?>
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |