PHP端:
$imgPath = $_POST['url'];
function imageCreateFromJpegEx($file)
{
$data = file_get_contents($file);
$im = @imagecreatefromstring($data);
$i = 0;
while (!$im)
{
$data = substr_replace($data, "", -3, -2);
$im = @imagecreatefromstring($data);
}
return $im;
}
$im = imageCreateFromJpegEx($imgPath);
imagejpeg( $im );
Flash调用方法:
function LoadImg(e:MouseEvent):void
{
//imgMovieClip为需要加载图片的MovieClip,目前好像不能用内置的组件UILoader来读取...
var imgURLRequest:URLRequest = new
URLRequest('get_images.php');
var imgURLLoader:URLLoader = new URLLoader(imgURLRequest);
var imgLoader:Loader = new Loader();
var imgURL:String = URL_Input.text;
var imgURLVariable:URLVariables = new URLVariables();
//
imgURLVariable.url = imgURL;
//imgURL即为需要跨域访问图片的URL
//
imgURLRequest.data = imgURLVariable;
imgURLRequest.method = URLRequestMethod.POST;
//URLRequestMethod 要用POST
//
imgLoader.load(imgURLRequest);
imgMovieClip.addChild(imgLoader);
}