IMGUR file upload via PHP and cURL

Koreani

New Member
I'm trying to upload an image to IMGUR via PHP.This is the code:\[code\]<?$filename = "image.jpg";$handle = fopen($filename, "r");$data = http://stackoverflow.com/questions/5640163/fread($handle, filesize($filename));// $data is file data$pvars = array('image' => base64_encode($data), 'mykey' => IMGUR_API_KEY);$timeout = 30;$curl = curl_init();curl_setopt($curl, CURLOPT_URL, 'http://api.imgur.com/2/upload.xml');curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);$xml = curl_exec($curl);curl_close ($curl);\[/code\]?>This is the error message I receive:\[quote\] Warning: fopen(image.jpg) failed to open stream: No such file or directory\[/quote\]I don't understand the part: $filename = "image.jpg"; Where does the filename come from since it's a base64 generated string? Thanks,Bob
 
Top