PHP从表单上传文件到Web服务器。错误信息 [英] PHP upload file to web server from form. error message

查看:187
本文介绍了PHP从表单上传文件到Web服务器。错误信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从php表单上传文件。
我已经通过ISP验证了目标位置为/ home / hulamyxr / public_html / POD /。

执行页面时出现以下错误:

 警告:move_uploaded_file(/ home / hulamyxr / public_html / POD / 1511.pdf)[function.move-uploaded-file ]:未能打开流:没有这样的文件或目录在/home/hulamyxr/public_html/hauliers/include/capturelocal2.php在线124 

警告:move_uploaded_file()[function.move-uploaded-文件]:无法将/home/hulamyxr/public_html/hauliers/include/capturelocal2.php上的'/ tmp / phpyp3ERS'移动到'/ home / hulamyxr / public_html / POD / 1511.pdf'124
POD成功上传交付1511.文件名::

我的表单代码

 < form enctype =multipart / form-datamethod =postaction =capturelocal2.php> 
< input type = file size = 6 name = ref1pod id = ref1pod>
< / form>

我的PHP代码上传文件

  $ ref1 = $ _POST [ref1]; //这是我想要文件的名称
$ ref1pod = $ _POST [ref1pod]; //这是输入字段的名称,格式为

move_uploaded_file($ _ FILES [ref1pod] [tmp_name],
/ home / hulamyxr / public_html / POD / 。($ ref1。。pdf));

任何帮助将不胜感激。
感谢和问候,
Ryan Smith

解决方案

代码中存在错误:



你需要改变你的move_uploaded_file函数。有一个额外的空间,我认为这是导致问题:

  move_uploaded_file($ _ FILES [ref1pod] [tmp_name ],/ home / hulamyxr / public_html / POD /。($ ref1。。pdf)); 

另外我不确定

  $ ref1 = $ _POST [ref1]; //这是我想要文件的名称
$ ref1pod = $ _POST [ref1pod];

来自。您的表单中没有这样的值。您是否仅上传仅带上传的表单?还要确保在表单和表单后值中加上引号。



是ref1和ref1pod是常量。如果你不加引号PHP将把它作为常量。如果它们不是常量,则变为:

  $ ref1 = $ _POST ['ref1']; //这是我想要的文件名
$ ref1pod = $ _POST ['ref1pod'];

同样在您的表单中,加上引号:

 < form enctype =multipart / form-datamethod =postaction =capturelocal2.php> 
< input type =filesize =6name =ref1podid =ref1pod/>
< / form>

确保您设置了上传文件夹的权限。



希望这可以帮助你:)

I am trying to upload a file from a php form. I have verified the target location with my ISP as being "/home/hulamyxr/public_html/POD/"

I get the below error when executing the page:

Warning: move_uploaded_file(/home/hulamyxr/public_html/POD/ 1511.pdf) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/hulamyxr/public_html/hauliers/include/capturelocal2.php on line 124

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpyp3ERS' to '/home/hulamyxr/public_html/POD/ 1511.pdf' in /home/hulamyxr/public_html/hauliers/include/capturelocal2.php on line 124
POD Successfully uploaded for delivery 1511. filename: :

My Form Code

<form enctype="multipart/form-data" method="post" action="capturelocal2.php">
<input type=file size=6 name=ref1pod id=ref1pod>
</form>

My PHP Code to upload the file

$ref1 = $_POST[ref1]; //this is the name I want the file to be
$ref1pod = $_POST[ref1pod]; // this is the name of the input field in the form

  move_uploaded_file($_FILES["ref1pod"]["tmp_name"],
  "/home/hulamyxr/public_html/POD/ " . ($ref1.".pdf"));

Any assistance will be greatly appreciated. Thanks and Regards, Ryan Smith

解决方案

There is an error in your code:

You need to change your move_uploaded_file funciton. There is an extra space i think which is causing the problem:

move_uploaded_file($_FILES["ref1pod"]["tmp_name"],"/home/hulamyxr/public_html/POD/" .($ref1.".pdf"));

Also i am not sure where is the

$ref1 = $_POST[ref1]; //this is the name I want the file to be
$ref1pod = $_POST[ref1pod];

coming from .There is no such values in your form. Did you upload only the form with upload only. Also be sure to put quotes around attribute values in your form and post value.

Is ref1 and ref1pod are constants. If you din't put quotes PHP will take it as constants. If they are not constants change to:

$ref1 = $_POST['ref1']; //this is the name I want the file to be
$ref1pod = $_POST['ref1pod'];

Also in your form, put quotes:

<form enctype="multipart/form-data" method="post" action="capturelocal2.php">
     <input type="file" size="6" name="ref1pod" id="ref1pod"/>
</form>

Be sure you set permissions to your upload folder .

Hope this helps you :)

这篇关于PHP从表单上传文件到Web服务器。错误信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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