文件未上传PHP [英] File not uploading PHP

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

问题描述

我试图编写代码以将文件上传到PHP中的"media"文件夹.由于某些原因,它仍然无法正常工作.

I've attempted to write code to have a file uploaded to a "media" folder in PHP. For some reason it continues to not work.

这是执行代码:

move_uploaded_file($_FILES["file"]["tmp_name"],"../media/" . $_FILES["file"]["name"]) or die ("Failure to upload content");

这是我的表单代码:

    <input type="file" name="file" id="file" /> 

任何想法为什么它可能无法正常工作?

Any ideas why it may not be working?

当我使用命令"print_r($ _ FILES);"时,它显示:

When I use the command "print_r($_FILES);", it displays:

Array([file] => Array([name] =>屏幕截图2012年5月29日下午12.36.11 PM.png [type] => image/png [tmp_name] =>/Applications/MAMP/tmp /php/phpHNj3nW [错误] => 0 [大小] => 71640))

Array ( [file] => Array ( [name] => Screen Shot 2012-05-29 at 12.36.11 PM.png [type] => image/png [tmp_name] => /Applications/MAMP/tmp/php/phpHNj3nW [error] => 0 [size] => 71640 ) )

图片未上传到文件夹中.

Image is NOT uploaded into the folder.

推荐答案

请确保在您的表单中输入enctype.
例如:<form method="post" enctype="multipart/form-data" action="index.php"></form>;

Make sure that in your form.. you put the enctype.
eg: <form method="post" enctype="multipart/form-data" action="index.php"></form>;

在提交表单后检查文件是否成功更新.使用print_r查看结果.
print_r($_FILES);

To check if files are successfully updated upon submitting the form. use print_r to see results.
print_r($_FILES);

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

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