在wideimage中输入文件

时间:2012-07-31 01:00:26

标签: php html image input

我有这些代码。在form.html

<form name="form2" method="post" action="lagarto.php" />
<input type="file" size="32" name="myimg" value="" />
<input type="submit" name="Submit" value="upload" />
</form>

lagarto.php

 <?php 

require( "./lib/WideImage.php");

$myimg = $_FILES['myimg']['tmp_name'];  // <-- Note this addition
$image = WideImage::load($myimg);



$image = WideImage::load($img);


$image->output('jpg', 90);

    ?>

它应显示图像输出但我收到此错误消息:

  

注意:未定义的索引:myimg in C:\ Arquivos de   programas \ EasyPHP-5.3.9 \ www \ wideimage-11.02.19-full \ lagarto.php on   第6行

     

致命错误:未捕获的异常   'WideImage_InvalidImageSourceException',消息'String不   包含图像数据。'在C:\ Arquivos de   计划成\的EasyPHP-5.3.9 \ WWW \ wideimage-19年2月11日全\ lib中\ WideImage.php:240   堆栈跟踪:#0 [内部函数]:WideImage :: loadFromString(NULL)    #1 C:\ Arquivos de programas \ EasyPHP-5.3.9 \ www \ wideimage-11.02.19-full \ lib \ WideImage.php(184):   call_user_func(Array,NULL)#2 C:\ Arquivos de   计划成\的EasyPHP-5.3.9 \ WWW \ wideimage-19年2月11日全\ lagarto.php(8):   在C:\ Arquivos de中抛出的WideImage :: load(NULL)#3 {main}   计划成\的EasyPHP-5.3.9 \ WWW \ wideimage - 19年2月11日全\ LIB \ WideImage.php   在第240行

有什么想法吗?

编辑: 我试着将这些行添加到我的代码中:

$_FILES = $HTTP_POST_FILES;
$img = $FILES['myimg']['tmp_name'];

我甚至只试过其中一条线。没有任何改变。

2 个答案:

答案 0 :(得分:0)

$myimg不会根据表单自动设置,您从未声明过。

您需要定义$myimg

之类的内容
$myimg = $_FILES['myimg']['tmp_name'];  // <-- Note this addition
$image = WideImage::load($myimg);

答案 1 :(得分:0)

我记得我有同样的问题。解决方案是将图像格式系统临时文件夹复制到本地文件夹,然后通过加载程序访问它。 (另一个原因可能是临时名称中的文件后缀不正确。)

相关问题