简体   繁体   English

上载png图片变黑

[英]Uploading png images going black

I have searched the web and found many treads on this one, but i can not find a solution for my issue. 我已经在网上搜索了很多内容,但是找不到适合我问题的解决方案。

I'm able to upload jpg and jpeg files, but when uploading png files, they turn out black. 我可以上传jpg和jpeg文件,但是上传png文件时,它们变成黑色。

This is my code for uploading the png files: 这是我上传png文件的代码:

$dest_image = imagecreatetruecolor($width, $height); 

if($image_extension == ".png"){
        $source_image = imagecreatefrompng($temp_png_file); 
        imagecopyresampled($dest_image, $source_image, 0, 0, 0, 0, $width, $height, $width, $height); 
        imagepng($dest_image, $folder.$new_name);
}

Thanks 谢谢

I found the problem, It was because of a mysql_real_escape_string() function than created the wrong value for $temp_png_file. 我发现了问题,这是由于mysql_real_escape_string()函数而不是为$ temp_png_file创建了错误的值。 Also, i had a problematic if() statement... 另外,我有一个有问题的if()语句...

Twice my own mistake :-/ 我自己的错误两次:-/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM