如何使用像<form enctype="multipart/form-data">
这样的PHP上传文件?
可以用PHP做到吗?
答案 0 :(得分:0)
http_post_fields()
看起来很有希望。
答案 1 :(得分:0)
试用本教程: http://www.tizag.com/phpT/fileupload.php
HTML:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
PHP:
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}