PHP上传文件 [英] PHP Uploading Files

查看:134
本文介绍了PHP上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用PHP上传文件时遇到问题。当我提交时,$ _FILES []是空的。我觉得这是一个这样的问题:/ b /

我的表单:

 < form method =postaction =uploadfile.php> 
< input type =hiddenname =MAX_FILE_SIZEvalue =300000/>
Image:< input name =ImageFiletype =file/>< br />
< input type =submitvalue =Add Image/>< br />
< / form>

相关php.ini:

 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;文件上传;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;是否允许HTTP文件上传
file_uploads =在

; HTTP上传文件的临时目录(如果不是
,则使用系统默认值)。
upload_tmp_dir =c:\ php5\upload\

;上传文件的最大允许大小。
upload_max_filesize = 300M

c:\ php5\upload\可由IUSR_HOSTNAME写入$ /

关于还有什么我应该检查的想法?

解决方案

确保您的表单标记具有此属性: enctype =multipart / form-data



如果没有它,文件将无法上传。 >

I'm having a problem uploading files in PHP. When I submit, $_FILES[] is empty. I feel like this is such a n00b question :/

My form:

<form method="post" action="uploadfile.php">
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
Image: <input name="ImageFile" type="file" /><br />
<input type="submit" value="Add Image" /><br />
</form>

Relevant php.ini:

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "c:\php5\upload\"

; Maximum allowed size for uploaded files.
upload_max_filesize = 300M

c:\php5\upload\ is writable by IUSR_HOSTNAME

Any thoughts on what else I should check?

解决方案

Make sure your form tag has this attribute: enctype="multipart/form-data"

Without it the files will not get uploaded.

这篇关于PHP上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆