Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/430.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP将文件从表单上载到web服务器。错误消息_Php_Forms_File_Upload - Fatal编程技术网

PHP将文件从表单上载到web服务器。错误消息

PHP将文件从表单上载到web服务器。错误消息,php,forms,file,upload,Php,Forms,File,Upload,我正在尝试从php表单上传一个文件。 我已与ISP验证目标位置为“/home/hulamyxr/public_html/POD/” 我在执行页面时遇到以下错误: 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/p

我正在尝试从php表单上传一个文件。 我已与ISP验证目标位置为“/home/hulamyxr/public_html/POD/”

我在执行页面时遇到以下错误:

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: :
我的表格代码

<form enctype="multipart/form-data" method="post" action="capturelocal2.php">
<input type=file size=6 name=ref1pod id=ref1pod>
</form>
任何帮助都将不胜感激。 感谢和问候,
Ryan Smith

检查文件夹名称,它们应区分大小写,还应检查POD文件夹是否具有777权限(CHMOD)

检查文件夹名称,它们应区分大小写,还应检查POD文件夹是否具有777权限(CHMOD)

代码中有错误:

您需要更改移动文件功能。我认为有一个额外的空间导致了问题:

move_uploaded_file($_FILES["ref1pod"]["tmp_name"],"/home/hulamyxr/public_html/POD/" .($ref1.".pdf"));
而且我也不知道电话号码在哪里

$ref1 = $_POST[ref1]; //this is the name I want the file to be
$ref1pod = $_POST[ref1pod];
来自。在你的表单中没有这样的值。您是否只上传了带有upload only的表单。还要确保在表单和post值中的属性值周围加引号

Is ref1和ref1pod是常数。如果不加引号,PHP将把它作为常量。如果它们不是常量,则更改为:

$ref1 = $_POST['ref1']; //this is the name I want the file to be
$ref1pod = $_POST['ref1pod'];
同样在您的表格中,加引号:

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

请确保已设置上载文件夹的权限


希望这对您有所帮助:)

您的代码中有一个错误:

您需要更改移动文件功能。我认为有一个额外的空间导致了问题:

move_uploaded_file($_FILES["ref1pod"]["tmp_name"],"/home/hulamyxr/public_html/POD/" .($ref1.".pdf"));
而且我也不知道电话号码在哪里

$ref1 = $_POST[ref1]; //this is the name I want the file to be
$ref1pod = $_POST[ref1pod];
来自。在你的表单中没有这样的值。您是否只上传了带有upload only的表单。还要确保在表单和post值中的属性值周围加引号

Is ref1和ref1pod是常数。如果不加引号,PHP将把它作为常量。如果它们不是常量,则更改为:

$ref1 = $_POST['ref1']; //this is the name I want the file to be
$ref1pod = $_POST['ref1pod'];
同样在您的表格中,加引号:

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

请确保已设置上载文件夹的权限


希望这对您有所帮助:)

同意Phil的意见,删除字符串和文件名之间的空格

"/home/hulamyxr/public_html/POD/ " . ($ref1.".pdf"));
                                ^
                                |
您也可以尝试以下方法:

$ref1 = $_POST[ref1];
$file_name = $_SERVER['DOCUMENT_ROOT'] . '/POD/' . $ref1 . '.pdf';
move_uploaded_file($_FILES['ref1pod']['tmp_name'], $file_name);

同意Phil的意见,删除字符串和文件名之间的空格

"/home/hulamyxr/public_html/POD/ " . ($ref1.".pdf"));
                                ^
                                |
您也可以尝试以下方法:

$ref1 = $_POST[ref1];
$file_name = $_SERVER['DOCUMENT_ROOT'] . '/POD/' . $ref1 . '.pdf';
move_uploaded_file($_FILES['ref1pod']['tmp_name'], $file_name);

请尝试以下代码

 <?php
 if(isset($_REQUEST['upload'])) {
   $filename    =   $_FILES['ref1pod']['tmp_name'];
   if (file_exists($_SERVER['DOCUMENT_ROOT']."/POD/".$_FILES["ref1pod"]["name"]))
       {
        echo $_FILES["ref1pod"]["name"] . " Already Exists. ";
       }
      else {
   $path = $_SERVER['DOCUMENT_ROOT']."/POD/".$_FILES['ref1pod']['name'];
       move_uploaded_file($filename,$path);         
  }
}
?>

<form enctype="multipart/form-data" method="post" action="">
 <input type=file size=6 name=ref1pod id=ref1pod>
 <input type="submit" name="upload" value="upload" />
</form>


请尝试以下代码

 <?php
 if(isset($_REQUEST['upload'])) {
   $filename    =   $_FILES['ref1pod']['tmp_name'];
   if (file_exists($_SERVER['DOCUMENT_ROOT']."/POD/".$_FILES["ref1pod"]["name"]))
       {
        echo $_FILES["ref1pod"]["name"] . " Already Exists. ";
       }
      else {
   $path = $_SERVER['DOCUMENT_ROOT']."/POD/".$_FILES['ref1pod']['name'];
       move_uploaded_file($filename,$path);         
  }
}
?>

<form enctype="multipart/form-data" method="post" action="">
 <input type=file size=6 name=ref1pod id=ref1pod>
 <input type="submit" name="upload" value="upload" />
</form>


是否存在
POD
目录,是否可由PHP脚本编写?您可以使用和来检查。另外,为什么
POD/
和目标文件之间有空格?您真的不应该允许用户在没有至少某种形式的验证的情况下选择文件名
POD
目录是否存在,它是否可由PHP脚本写入?您可以使用和来检查。另外,为什么
POD/
和目标文件之间有空格?您确实不应该允许用户在没有至少某种形式的验证的情况下选择文件名