我想上传从PHP格式的文件。 我与我的ISP为验证目标位置“/家庭/ 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>
我的PHP代码上传的文件
$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"));
任何援助将不胜感激。 感谢和问候,莱恩·史密斯
有一个在你的代码中的错误:
您需要更改您的move_uploaded_file功能可按。 有一个额外的空间,我认为这是造成问题的原因:
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];
从未来。有在你的表格没有这样的价值观。 难道你只上传的形式只能上传。 此外,一定要放周围的属性值引号的形式和岗位价值。
是REF1和ref1pod是常数。 如果您din't把报价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>
要确保你设置权限,上传的文件夹。
希望这可以帮助你:)
检查文件夹名称,他们应该是大小写敏感的,并且还检查POD文件夹有777个权限(CHMOD)
菲尔同意,删除字符串和文件名之间的空间
"/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>
http://patelmilap.wordpress.com/2012/01/30/php-file-upload/
文章来源: PHP upload file to web server from form. error message