查看: 1031|回复: 1
|
PHP upload image....
[复制链接]
|
|
<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...... |
|
|
|
|
|
|
|
发表于 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问我。。 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|