佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1031|回复: 1

PHP upload image....

[复制链接]
发表于 29-7-2006 11:14 PM | 显示全部楼层 |阅读模式
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>

<form action="getfile.php" enctype="multipart/form-data" method="post"> <br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>

</body>
</html>

*********************************************
<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
$uploaddir = '../uploads/';
$uploadfile = $uploaddir . $HTTP_POST_FILES['uploadFile']['name'];

if (move_uploaded_file($HTTP_POST_FILES['uploadFile']['tmp_name'], $uploadfile)) {
   print "File is valid, and was successfully uploaded. ";
   print "Here's some more debugging info:\n";
   print_r($_FILES);
} else {
   print "Possible file upload attack!  Here's some debugging info:\n";
   print_r($_FILES);
}
?>
</body>
</html>



我试了很多次。。。。
他给我的error是
Warning: move_uploaded_file(../uploads/pepperkenny-1-2.jpg): failed to open stream: Permission denied in c:\inetpub\wwwroot\e-shop\php\getfile.php on line 10

Warning: move_uploaded_file(): Unable to move 'C:\WINDOWS\TEMP\php1EBF.tmp' to '../uploads/pepperkenny-1-2.jpg' in c:\inetpub\wwwroot\e-shop\php\getfile.php on line 10
Possible file upload attack! Here's some debugging info: Array ( [uploadFile] => Array ( [name] => pepperkenny-1-2.jpg [type] => image/pjpeg [tmp_name] => C:\WINDOWS\TEMP\php1EBF.tmp [error] => 0 [size] => 255899 ) )

help me pls.......urgent.....
thank you......
回复

使用道具 举报


ADVERTISEMENT

Calverstine 该用户已被删除
发表于 31-7-2006 12:09 AM | 显示全部楼层
你好!!
我是install apache 2.0 我的coding 可以跑!! 我想是你的文件簿 permission 没有set 好。以下是我的coding:

$source=$_FILES["file"]["tmp_name"];
$type=$_FILES["file"]["type"];
$ext = substr(strrchr($type, "/" ), 1);
switch ( $ext )
{
        case 'pjpeg':
        $dest = $uploadpath.uniqid('_id').'.jpg';
        $resume_path = uniqid('_id').'.jpg';
        break;
        case 'jpeg':
        $dest = $uploadpath.uniqid('_id').'.jpeg';
        $resume_path = uniqid('_id').'.jpeg';
        break;
        case 'gif':
        $dest = $uploadpath.uniqid('_id').'.gif';
        $resume_path = uniqid('_id').'.gif';
        break;
        default:
        echo '<BR> File type unknown, please upload your photograph in gif or jpg file <BR>'. $ext;
        break;
}
move_uploaded_file($source, $dest) or die ("UPLOAD_FILES():: Corrupted file when uploading images" ) ;
如果你有舍么问题,欢迎你email问我。。
回复

使用道具 举报

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

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


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

GMT+8, 13-8-2025 02:18 AM , Processed in 0.113293 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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