佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1125|回复: 9

[PHP] Upload and Resize的问题

[复制链接]
发表于 31-7-2006 01:31 PM | 显示全部楼层 |阅读模式
我在这个网看到这样的code.

http://www.fundisom.com/phparadise/php/image_handling/image_upload_and_resize#51

但是当我要run的时候没有问题。
but,要upload的时候就中招了。

下面是我的error message


  1. Warning: move_uploaded_file(pics/122935.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\share\upload2.php on line 18

  2. Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\PHP\uploadtemp\php11.tmp' to 'pics/122935.jpg' in D:\share\upload2.php on line 18

  3. Warning: chmod() [function.chmod]: No such file or directory in D:\share\upload2.php on line 19

  4. Warning: getimagesize(pics/122935.jpg) [function.getimagesize]: failed to open stream: No such file or directory in D:\share\upload2.php on line 20

  5. Warning: Division by zero in D:\share\upload2.php on line 21

  6. Fatal error: Call to undefined function ImageCreateTrueColor() in D:\share\upload2.php on line 30
复制代码


感觉上我好像少了一些东西。

我是用IIS+PHP5的。

谢谢
回复

使用道具 举报


ADVERTISEMENT

发表于 31-7-2006 07:15 PM | 显示全部楼层
问题是出在$filedir,用full path吧。例如 c;/upload
回复

使用道具 举报

 楼主| 发表于 1-8-2006 09:14 AM | 显示全部楼层
原帖由 苦瓜汤 于 31-7-2006 07:15 PM 发表
问题是出在$filedir,用full path吧。例如 c;/upload



这样的话不就是很麻烦了吗???
如果我还要upload上server的。。。。。

但结果是出error.
line 30

  1. $destimg=ImageCreateTrueColor($new_width,$new_height)
  2. or die('Problem In Creating image');

复制代码


Fatal error: Call to undefined function ImageCreateTrueColor() in D:\share\upload2.php on line 30
回复

使用道具 举报

发表于 1-8-2006 01:07 PM | 显示全部楼层
原帖由 红发 于 1-8-2006 09:14 AM 发表



这样的话不就是很麻烦了吗???
如果我还要upload上server的。。。。。

但结果是出error.
line 30

$destimg=ImageCreateTrueColor($new_width,$new_height)
or die('Problem In Creating image' ...

1。file path不同uri,比较好使用full path,把它放到一个variable或constant不怎么麻烦吧?
2。第二个error,检查一下你的gd extension有没有loaded。extension=php_gd2.dll

[ 本帖最后由 苦瓜汤 于 1-8-2006 01:08 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 2-8-2006 11:25 AM | 显示全部楼层
原帖由 苦瓜汤 于 1-8-2006 01:07 PM 发表

1。file path不同uri,比较好使用full path,把它放到一个variable或constant不怎么麻烦吧?
2。第二个error,检查一下你的gd extension有没有loaded。extension=php_gd2.dll



可以upload了,但是。。。。
他的size没有变到。。。。

还中了一个error呢。

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'pics/small_122935.jpg' for writing in D:\share\upload2.php on line 36
Problem In saving
回复

使用道具 举报

发表于 2-8-2006 12:58 PM | 显示全部楼层
原帖由 红发 于 2-8-2006 11:25 AM 发表



可以upload了,但是。。。。
他的size没有变到。。。。

还中了一个error呢。

Warning: imagejpeg() : Unable to open 'pics/small_122935.jpg' for writing in D:\share\upload2.php on line 36
Pr ...


你没有用 fullpath? 你的 path 是怎么样的?
回复

使用道具 举报

Follow Us
 楼主| 发表于 2-8-2006 01:15 PM | 显示全部楼层
原帖由 goatstudio 于 2-8-2006 12:58 PM 发表


你没有用 fullpath? 你的 path 是怎么样的?


知道了原来这个也要。。。

  1. $thumbdir = 'D:/share/img'
复制代码

[ 本帖最后由 红发 于 2-8-2006 01:20 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 3-8-2006 10:01 AM | 显示全部楼层
还有一个问题。。。


  1. <?php
  2. if(isset($_POST['Submit']))
  3. {
  4. $size = 150; // the thumbnail height
  5. $filedir = 'pics/'; // the directory for the original image
  6. $thumbdir = 'pics/'; // the directory for the thumbnail image
  7. $prefix = 'small_'; // the prefix to be added to the original name
  8. $maxfile = '2000000';
  9. $mode = '0666';
  10. $userfile_name = $_FILES['image']['name'];
  11. $userfile_tmp = $_FILES['image']['tmp_name'];
  12. $userfile_size = $_FILES['image']['size'];
  13. $userfile_type = $_FILES['image']['type'];
  14.     IF ($userfile_type == "JPEG"){
  15.     ................
  16.     。。。。。。。。
  17.     }
  18.     ELSE{
  19.       header("Location: upload.php");
  20.    }
复制代码


为何我要在手动refresh多一次他才会去到upload.php这里呢?



[/code]
回复

使用道具 举报


ADVERTISEMENT

发表于 3-8-2006 10:18 AM | 显示全部楼层

ELSE{
      header("Location: upload.php");
   }
[/red]
只要你上传的文件是JPEG都不会回到upload.php
回复

使用道具 举报

 楼主| 发表于 3-8-2006 10:40 AM | 显示全部楼层
原帖由 苦瓜汤 于 3-8-2006 10:18 AM 发表

ELSE{
      header("Location: upload.php");
   }

只要你上传的文件是JPEG都不会回到upload.php



  1. <?
  2. $action=$_GET['action'];

  3.         if ($action=="success") {
  4.                 echo "success";
  5.         }else{
  6.                 echo "fail";
  7.         }
  8.        
  9. ?>
复制代码


为何我用IIS+PHP这样写会有error的???

Notice: Undefined index: action in D:\share\upload3.php on line 3

[ 本帖最后由 红发 于 3-8-2006 02:02 PM 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 12-8-2025 11:32 PM , Processed in 0.133609 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表