NewGuy21 Posted May 19, 2007 Share Posted May 19, 2007 Ok so I was having so many problems writing a php transload (to copy file from one server to other) script. So I made an image one that works using curl. It doesnt upload it yet, it just grabs it and then shows what you grabbed in your browser. I havnt worked all the stuff out of the curl upload part. But lemme know what think. http://www.escapesanity.com/curl.php Link to comment https://forums.phpfreaks.com/topic/52146-test-my-transload-curl-script/ Share on other sites More sharing options...
NewGuy21 Posted May 19, 2007 Author Share Posted May 19, 2007 Blah I forgot to mention this only works for .jpeg files. I have limited it to that for testing purposes Link to comment https://forums.phpfreaks.com/topic/52146-test-my-transload-curl-script/#findComment-257210 Share on other sites More sharing options...
john010117 Posted May 20, 2007 Share Posted May 20, 2007 No error messages for the most part. It works fine. Link to comment https://forums.phpfreaks.com/topic/52146-test-my-transload-curl-script/#findComment-257301 Share on other sites More sharing options...
seb hughes Posted May 20, 2007 Share Posted May 20, 2007 Work, mind sharing your code? Link to comment https://forums.phpfreaks.com/topic/52146-test-my-transload-curl-script/#findComment-257774 Share on other sites More sharing options...
NewGuy21 Posted May 21, 2007 Author Share Posted May 21, 2007 This is just basic curl code. Though what im working on is trying to save it then run it through my exsisting php code. But having problems bridging it. But anyway here is that code Enjoy This is the core you can add statements to define file type I switched out mine that only did jpeg now this should work for any image file <?php $image_url = "$_POST[sourceurl]"; $ch = curl_init(); $timeout = 0; $fp = fopen("image.jpg", "w"); curl_setopt ($ch, CURLOPT_URL, $image_url); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt ($ch, CURLOPT_FILE, $fp); // Getting binary data curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); $thefile = curl_exec($ch); curl_close($ch); // output to browser header("Content-type: image/jpeg"); print $thefile; ?> <html> <form name="input" method="post" action="curl.php"> File: <input type="text" name="sourceurl"> <input type="submit" value="Submit"> </form> </html> Link to comment https://forums.phpfreaks.com/topic/52146-test-my-transload-curl-script/#findComment-258400 Share on other sites More sharing options...
dsaba Posted May 24, 2007 Share Posted May 24, 2007 here's a good page that gives you many examples of how to use libcurl with php: http://curl.haxx.se/libcurl/php/examples/ Link to comment https://forums.phpfreaks.com/topic/52146-test-my-transload-curl-script/#findComment-260475 Share on other sites More sharing options...
Recommended Posts