cURL从链接获取图像

I have a script in php how download images from a partner website.

The script looks like

function getimg($url) {
    $headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';
    $headers[] = 'Connection: Keep-Alive';
    $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
    $user_agent = 'php';
    $process = curl_init($url);
    curl_setopt($process, CURLOPT_USERPWD, "username:password");
    curl_setopt($process, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($process, CURLOPT_HEADER, 0);
    curl_setopt($process, CURLOPT_USERAGENT, $user_agent);
    curl_setopt($process, CURLOPT_TIMEOUT, 30);
    curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
    $return = curl_exec($process);
    curl_close($process);
    return $return;
}

The problem is because partner was put a password on his website. the website url is www.importatorarticolecopii.ro/feeds/general_feed2.php

I put the user and password in curl but not work...

Need some help

</div>

Your code is fine, the problem is from your given url Increase your timeout as the url given above is too slow and try to don't exceed the maximum execution time of your server.

curl_setopt($process, CURLOPT_TIMEOUT, 60);

and use a user agent for example :

$user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/2php0050915 Firefox/1.0.7)';

and in future try to catch your errors to check what's your issue

if(curl_error($process))
{
echo 'error:' . curl_error($process);
}