Je hebt nog geen image gekozen, of het bestand is te groot
"; } ?> 60000000)) {// Bericht voor als het is verstuurd maar groter is dan 60kb echo "het bestand is te groot, probeer het nogmaals"; } ?>Titel:
Beschrijving:
De volgende categorieën bestaan op deze website:
U kunt deze overnemen, of een nieuwe categorie toevoegen. Dit doet u door gewoon een nieuwe categorie te typen.
Categorie:
Image:
I have now four warning with this script, can anyone explain why I get this warnings? The warnings are:
我现在有四个警告这个脚本,任何人都可以解释为什么我得到这个警告?警告是:
Warning: imagecreatefromstring(): Empty string or invalid image in *MY URL* on line 24 Warning: imagesx() expects parameter 1 to be resource, boolean given in *MY URL* on line 25 Warning: imagesy() expects parameter 1 to be resource, boolean given in *MY URL* on line 26 Warning: imagecopyresized() expects parameter 2 to be resource, boolean given in *MY URL* on line 36
1 个解决方案
#1
0
Read the documentation of the imagejpeg()
function. The way you call it will directly output the image to the output buffer. The variable $tn
only contains a resource identifier. You could use ob_start()
and ob_get_flush()
(documentation) around the imagejpg()
call to fetch the actual image without writing it to a file:
阅读imagejpeg()函数的文档。您调用它的方式将直接将图像输出到输出缓冲区。变量$ tn仅包含资源标识符。您可以在imagejpg()调用周围使用ob_start()和ob_get_flush()(文档)来获取实际图像,而无需将其写入文件:
ob_start();
imagejpeg($tn);
$image_cOntents= ob_get_flush();
// Now write $image_contents to the database, instead of $tn
However, it would be advisable to actually write the image to the file system and store the path to it in the database. That way the image can be served as a static file, which will increase performance in all ways.
但是,建议将图像实际写入文件系统并将其路径存储在数据库中。这样,图像可以作为静态文件提供,这将以各种方式提高性能。