可以发觉连简单的上传都有问题.于是我在PHP手册里面找了关于文件上传的帮助.如下:
form.html
-------------------
<form enctype="multipart/form-data" action="upload7.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
-----------------------------uplaod7.php<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.$uploaddir = '/AppServ/www/upload';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}echo 'Here is some more debugging info:';
print_r($_FILES);print "</pre>";?> 当点击Send File是却弹出一个下载upload7.php的对话框.这到底是什么问题?
请各路高手帮忙看看...
呵呵..
小弟谢过了.
form.html
-------------------
<form enctype="multipart/form-data" action="upload7.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
-----------------------------uplaod7.php<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.$uploaddir = '/AppServ/www/upload';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}echo 'Here is some more debugging info:';
print_r($_FILES);print "</pre>";?> 当点击Send File是却弹出一个下载upload7.php的对话框.这到底是什么问题?
请各路高手帮忙看看...
呵呵..
小弟谢过了.
Uploading file...Warning: move_uploaded_file(/uploads/atoz.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in c:\Inetpub\wwwroot\18\upload.php on line 34Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\TEMP\php62.tmp' to '/uploads/atoz.txt' in c:\Inetpub\wwwroot\18\upload.php on line 34
Problem: Could not move file to destination directory
---------------------------------
right
我的问题解决了.
不是没有写权限而是文件路径的问题.
比如把$uploaddir = '/AppServ/www/upload';
改为$uploaddir = ./upload';就可以了..
可是这样的话.新的问题又来了..
因为./是在当前目录下打开的下一层路径.
但我想要我是出到当前目录的上一层目录才新建一个放置文件的文件夹.这样的话.我应该怎么改写个这个路径???
请各位大虾帮忙一下吧......