/    Sign up×
Community /Pin to ProfileBookmark

cURL and image upload

There is a cURL that processes the image and sends it to the server:

[code=php]if ($_POST[“upload”]) {
define(‘BASEPATH’, str_replace(‘\’, ‘/’, dirname(__FILE__)) . ‘/’);
$upload_url = $_POST[“upload”];
$post_params[‘file1’] = ‘@’.BASEPATH.’01.jpg’;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $upload_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);

echo $result;
}[/code]

In this case it takes the path (‘@’.BASEPATH.’01.jpg’) to the images with strictly specified name on my server… But how to take an image through a link with a variable (../image.php?image_id=’.$img.’) where $img is the name/number of image? Thanx

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@TecBratMay 12.2012 — I'm out of practice with this specific task, but I wrote this a while back. Maybe it will help you:

cURL multipart from data file upload.
×

Success!

Help @justman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...