Need some help with CURL |
Hello,
I am currently using CodeIgniter 2.2.3 and I am trying to execute a CURL Statement which requires me to use '@' before the FileURL. The problem is, I am running php 5.5.9 and using '@' before URL has been deprecated after php 5.5. I tried using $data = array( 'file' => new CURLFile($filePath) ); But this doesn't seem to run correctly when I execute the script. Digging a few more thing, I found out it is necessary to set CURLOPT_SAFE_UPLOAD to true, so I did that as well, but its still not working! I get no reply from the API Server whatsoever! I asked the API Developer to test my code and he said it worked perfectly fine for him (just running it using plain PHP), but with CodeIgniter, I am not able to run the script correctly. What am I doing wrong? Is there anything else that has to be done? Thanks,
Well... maybe you can start by posting the code snippet that is not working? I'm using CURL in a CodeIgniter project and it's working fine. CI is not the problem here.
Do you have any options, or is cURL all you get? I usually use phpseclib for file transfers to other servers, as its implementation of SFTP makes it super easy to use. I've used cURL a lot, and used it with CodeIgniter a lot. CodeIgniter doesn't do anything to inhibit your cURL usage, so if it's not working it's your code, your server, your firewall, your ISP, etc.
(12-17-2015, 06:44 PM)includebeer Wrote: Well... maybe you can start by posting the code snippet that is not working? I'm using CURL in a CodeIgniter project and it's working fine. CI is not the problem here. Thanks for you reply and sry for my late reply... Here is the code.... PHP Code: //$somefile_info['file'] = name_of_somefile.extension Let me know what's wrong with this... (12-17-2015, 09:19 PM)skunkbad Wrote: Do you have any options, or is cURL all you get? I usually use phpseclib for file transfers to other servers, as its implementation of SFTP makes it super easy to use. I've used cURL a lot, and used it with CodeIgniter a lot. CodeIgniter doesn't do anything to inhibit your cURL usage, so if it's not working it's your code, your server, your firewall, your ISP, etc. Not really, the website I am trying to upload the file to, only has an API, which I can connect to, only using CURL. It can not actually be my server because, this problem is arising only when I try to use new CURLFile() or curl_file_create() function. I have tried to connect to another site using CURL (which doesn't require '@') before the URL and it works perfectly fine (without CURLFile). The problem is with the API's that allow file upload using '@' before URL, that is, where new CURLFile() is required... Let me know what I am doing.... Btw, thanks for replying...
Check for curl error :
PHP Code: if(curl_exec($ch) === false)
(12-20-2015, 07:19 AM)includebeer Wrote: Check for curl error : Thanks for reply includebeer. It seems I was doing a very silly mistake here... When I used the curl_error($ch), t first gave me this error : Code: Error : couldn't open file "http://somesite.com/uploads/somefiles/folder/1/name_of_somefile.extension" After digging a little bit more on that, I came to know that CURLFile can only take relative paths as input. And then, when I changed the array to this... It started working!!! PHP Code: $details = array('name' => $new_name_for_api, 'category' => 28, 'apikey' => 'd67276793f5c9158e977cc34104e07c2', 'somefile' => new CURLFile('var/someperson/somethingsomething/somesite/uploads/somefiles/folder/'.$somefile_info['folder_id'].'/'.$somefile_info['file'])), 'descr' => 'Visit Us http://somesite.com/'); Thanks for all your help! ![]() |
Welcome Guest, Not a member yet? Register Sign In |