【发布时间】:2013-04-08 03:12:15
【问题描述】:
我已经为我的页面上的图片实现了文件上传,并试图以某种方式生成缩略图,以便通过fancybox单击它们进行查看。上传有效,但我创建缩略图的功能无效。 (这包含在我的 upload.php 中,就在“move_uploaded_file”之后:
<?php
$src = $subdir.$fileupload['name'];
function make_thumb($src)
{
$source_image = imagecreatefromjpeg($src); //For testing purposes only jpeg now
$width = imagesx($source_image);
$height = imagesy($source_image);
$desired_width = 220;
$desired_height = floor($height * ($desired_width / $width));
$virtual_image = imagecreatetruecolor($desired_width, $desired_height);
imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
header("Content-type: image/jpeg");
imagejpeg($virtual_image, realpath('./Thumbnails/filename.jpg')); //Temporary filename, will be changed
}
?>
仅供参考,这是一项作业,由于我是 php 初学者,我确实使用了 google,但在我的情况下找不到问题。可能是我对php的了解太少了。
【问题讨论】:
-
请启用错误报告,这样您就可以开始从 PHP 试图告诉您的问题中学习。
-
出了什么问题?是有错误还是没有按预期运行?
-
1.) 可以,需要先检查如何启用错误报告。 2.) 没有错误,什么都没有发生,我觉得这很奇怪,因为我的 php 经验伴随着很多错误消息
-
所以,在启用错误报告 (error_reporting(E_ALL);) 之后,什么都没有弹出。所以我猜有些东西在起作用,只是不像我想要的那样。
标签: php image upload thumbnails