0

我正在尝试调整大小,然后使用 php-image-magician 上传图像。但我无法保存图像。请看一下代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Upload</title>
</head>
<body>
<?php

if (isset($_POST['submit'])) {

require_once('php-image-magician/php_image_magician.php');


// *** Step 1 of 2) Set up the variables
$formInputName   = 'img-upload';                            # This is the name given to the form's file input
$savePath        = 'output3';                               # The folder to save the image
$saveName        = 'test';                                  # Without ext
$allowedExtArray = array('.jpg', '.png', '.gif', '.bmp');   # Set allowed file types
$imageQuality    = 100;


// *** If the form has been submitted...    
if (isset($_POST['submit'])) {
$error = '';        

// *** Create object
$magicianObj = new imageLib($formInputName, $savePath, $saveName , $allowedExtArray);

// *** If everything is swell, continue...
if ($umagicianObj->getIsSuccessful()) {
#=------------------------------------------------------------------

// *** Step 2 of 2) Add your image processing code here.

$magicianObj -> resizeImage(100, 100);
$magicianObj -> greyScaleDramatic();

#=------------------------------------------------------------------        
$magicianObj -> saveImage($savepath, $imageQuality);
} else {

// *** If there was an error, save it.
$error = $magicianObj->getError();
}

}
// *** Display
echo '<img src="' . $magicianObj->$savepath() . '">';
}

?>

<!-- The form. Not the name "img-upload" -->
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="img-upload" value="" />
<input type="submit" value="upload" name="submit" />
</form>

</body>
</html>

请解释我该怎么做,我做错了什么。

等待你的回复

带着敬意

4

2 回答 2

0

我想你忘了添加文件名$savepath

saveImage($savepath, ... )

编辑:

它是源代码的一部分:

public function saveImage($savePath, $imageQuality="100")
# Param in:   $savePath: Where to save the image including filename:
于 2013-07-01T02:34:33.027 回答
0

您的保存路径应该是确切的图像链接!不仅是文件夹名称,它还应该包括文件名和格式。

尝试:

saveImage($savepath.$savename.".jpg", $imageQuality)
于 2015-06-12T15:25:38.187 回答