Php WideImage仅适用于某些图像
WideImage仅适用于某些图像。我不明白为什么,因为图像是相同的文件类型和尺寸 这是我的密码Php WideImage仅适用于某些图像,php,thumbnails,gd,wideimage,Php,Thumbnails,Gd,Wideimage,WideImage仅适用于某些图像。我不明白为什么,因为图像是相同的文件类型和尺寸 这是我的密码 <?php error_reporting(E_ALL); include 'WideImage/WideImage.php'; function make_thumb($src, $dest, $desired_width) { try { WideImage::loadFromFile($src)->resize($desired_width, 50)-&
<?php
error_reporting(E_ALL);
include 'WideImage/WideImage.php';
function make_thumb($src, $dest, $desired_width) {
try {
WideImage::loadFromFile($src)->resize($desired_width, 50)->saveToFile($dest);
}
catch (Exception $e) {
echo 'EXCEPTION: '.$e;
}
}
?>
我收到以下错误:
编辑:此错误仅在我使用firebug重新发送数据时发生。起初没有显示错误
拇指创建已启动异常:异常
“WideImage_InvalidImageSourceException”与消息“文件”
“/kunden/homepages/33/d582216481/htdocs/uploads/downloads/image
.png'似乎是无效的图像源。'in
/主页/33/d582216481/htdocs/包括
/WideImage/WideImage.php:226堆栈跟踪:
0/homepages/33/d582216481/htdocs/includes/phpThumb.php(12):
WideImage::loadFromFile(“/kunden/homepag…”)
1/homepages/33/d582216481/htdocs/includes/addDownload.php(60):
制作拇指('/kunden/homepag…','/kunden/homepag…',100)
2{main}拇指创建已开始
有人能解释一下,为什么它对某些图像有效,而对某些图像无效
<?php
error_reporting(E_ALL);
// Basic Conf
require_once ('basic_config.php');
// PHP Thumb
require_once ('phpThumb.php');
// DB INIT
require_once ($full_url.'includes/db.php');
// GET DATA FROM POST
$pid = $_POST['downloadProdukt'];
$downloadBezeichnung = $_POST['downloadBezeichnung'];
$downloadDatei = str_replace(' ', '_', $_FILES['downloadDatei']['name']);
$downloadKategorie = $_POST['downloadKategorie'];
$downloadSize = $_FILES['downloadDatei']['size'];
// GET Image adjustments
$image_info = getimagesize($_FILES["downloadDatei"]["tmp_name"]);
$image_width = $image_info[0];
$image_height = $image_info[1];
// GET FOLDER OF THE PRODUCT
$cols = Array ("PID","OrdnerName");
$db->where ('PID', $pid);
$produkte = $db->get ("produkt", null, $cols);
if ($db->count > 0){
foreach ($produkte as $produkt) {
$uploadFolder = $produkt['OrdnerName'];
}
}
// FILE
$filePath = $upload_url . $uploadFolder . "downloads/";
$rel_file_path = $uploadFolder . "downloads/";
$filename = $filePath . $downloadDatei;
$thumbname = $filePath . "thumb_" . $downloadDatei;
// Falls Ordner nicht existiert erstelle neu
if (!file_exists($filePath)) {
mkdir($filePath, 0777, true);
}
// Move file to Dir
if (move_uploaded_file($_FILES['downloadDatei']['tmp_name'], $filename)) {
//echo "Original Datei erfolgreich hochgeladen.\n";
} else {
echo "Möglicherweise eine Dateiupload-Attacke!\n";
}
// IF Image --> Generate Thumb
if (
// Wenn dateityp BILD
$_FILES['downloadDatei']['type'] == 'image/jpeg' OR
$_FILES['downloadDatei']['type'] == 'image/png' OR
$_FILES['downloadDatei']['type'] == 'image/gif'
){
echo 'Thumb Creation Started';
make_thumb($filename, $thumbname, 100);
$thumbname = "thumb_" . $downloadDatei;
echo 'Thumb Creation Finished';
} else {
$thumbname = null;
echo 'Kein Thumb';
}
// EXECUTE QUERY
$data = Array ("PID" => $pid,
'DownloadBez' => $downloadBezeichnung,
'DownloadKat' => $downloadKategorie,
'DownloadDatei' => $downloadDatei,
'DownloadOrdner' => $rel_file_path,
'DownloadSize' => $downloadSize,
'DownloadThumb' => $thumbname
);
$id = $db->insert ('downloads', $data);
它是否与文件类型有关?所有的图片都是png还是jpg?都是png和相同的尺寸如果你检查源代码是否正确,我看到图片和.png之间有一个空格。这是真的吗?没有空格或任何特殊字符我认为空格是由firebug的复制粘贴造成的,因为文件类型在新行中它与文件类型有关系吗?所有的图片都是png还是jpg?都是png和相同的尺寸如果你检查源代码是否正确,我看到图片和.png之间有一个空格。这是真的吗?没有空格或任何特殊字符我认为空格是由firebug的复制粘贴造成的,因为文件类型在新行中
<?php
error_reporting(E_ALL);
// Basic Conf
require_once ('basic_config.php');
// PHP Thumb
require_once ('phpThumb.php');
// DB INIT
require_once ($full_url.'includes/db.php');
// GET DATA FROM POST
$pid = $_POST['downloadProdukt'];
$downloadBezeichnung = $_POST['downloadBezeichnung'];
$downloadDatei = str_replace(' ', '_', $_FILES['downloadDatei']['name']);
$downloadKategorie = $_POST['downloadKategorie'];
$downloadSize = $_FILES['downloadDatei']['size'];
// GET Image adjustments
$image_info = getimagesize($_FILES["downloadDatei"]["tmp_name"]);
$image_width = $image_info[0];
$image_height = $image_info[1];
// GET FOLDER OF THE PRODUCT
$cols = Array ("PID","OrdnerName");
$db->where ('PID', $pid);
$produkte = $db->get ("produkt", null, $cols);
if ($db->count > 0){
foreach ($produkte as $produkt) {
$uploadFolder = $produkt['OrdnerName'];
}
}
// FILE
$filePath = $upload_url . $uploadFolder . "downloads/";
$rel_file_path = $uploadFolder . "downloads/";
$filename = $filePath . $downloadDatei;
$thumbname = $filePath . "thumb_" . $downloadDatei;
// Falls Ordner nicht existiert erstelle neu
if (!file_exists($filePath)) {
mkdir($filePath, 0777, true);
}
// Move file to Dir
if (move_uploaded_file($_FILES['downloadDatei']['tmp_name'], $filename)) {
//echo "Original Datei erfolgreich hochgeladen.\n";
} else {
echo "Möglicherweise eine Dateiupload-Attacke!\n";
}
// IF Image --> Generate Thumb
if (
// Wenn dateityp BILD
$_FILES['downloadDatei']['type'] == 'image/jpeg' OR
$_FILES['downloadDatei']['type'] == 'image/png' OR
$_FILES['downloadDatei']['type'] == 'image/gif'
){
echo 'Thumb Creation Started';
make_thumb($filename, $thumbname, 100);
$thumbname = "thumb_" . $downloadDatei;
echo 'Thumb Creation Finished';
} else {
$thumbname = null;
echo 'Kein Thumb';
}
// EXECUTE QUERY
$data = Array ("PID" => $pid,
'DownloadBez' => $downloadBezeichnung,
'DownloadKat' => $downloadKategorie,
'DownloadDatei' => $downloadDatei,
'DownloadOrdner' => $rel_file_path,
'DownloadSize' => $downloadSize,
'DownloadThumb' => $thumbname
);
$id = $db->insert ('downloads', $data);