Jump to content

Test my Transload Curl script


Recommended Posts

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.



Link to comment
Share on other sites

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 :)



$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);

// output to browser
header("Content-type: image/jpeg");
print $thefile;


<form name="input" method="post" action="curl.php">

<input type="text" name="sourceurl">
<input type="submit" value="Submit">

Link to comment
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.