无法上传文件到服务器
Unable to upload file to the server
这是我用于上传文件的 php 文件,但我收到类似 没有这样的目录 我的代码有什么问题的错误?
upload.php
<?php
$vdo=$_FILES['uf']['name']; $target_path = "/photo";
$target_path = $target_path . basename( $_FILES['uf']['name']);
$target_path . basename( $_FILES['uf']['name']);
if(move_uploaded_file($_FILES['uf']['tmp_name'], $target_path))
?>
upload.php 文件与我的照片目录在同一个文件夹中 非常感谢任何帮助!
您需要在
之后添加 /
$target_path
$target_path = "/photo/";
因此,变量 $target_path
正在获取
前面的文件夹名称
上传的文件名。
您正在创建这样的路径:
/photoTheFileName.ext
这有两个问题:
首先,目录名和文件名之间没有/
。
当你解决这个问题时:
$target_path = "/photo/";
则路径为文件系统路径,将从文件系统的root开始。
你说:
upload.php file is in the same folder wher my Photo directory is
因此您希望目标路径类似于:
$target_path = "/hosts/www.example.com/htdocs/photo/";
…对您的文件系统进行适当的调整。
错误在第3行,你在目录名前加斜线,必须放在路径名后 $target_path="photo/";
<?php
$vdo=$_FILES['uf']['name']; $target_path = "photo/";
$target_path = $target_path . basename( $_FILES['uf']['name']);
$target_path . basename( $_FILES['uf']['name']);
if(move_uploaded_file($_FILES['uf']['tmp_name'], $target_path))
?>
这是我用于上传文件的 php 文件,但我收到类似 没有这样的目录 我的代码有什么问题的错误?
upload.php
<?php
$vdo=$_FILES['uf']['name']; $target_path = "/photo";
$target_path = $target_path . basename( $_FILES['uf']['name']);
$target_path . basename( $_FILES['uf']['name']);
if(move_uploaded_file($_FILES['uf']['tmp_name'], $target_path))
?>
upload.php 文件与我的照片目录在同一个文件夹中 非常感谢任何帮助!
您需要在
之后添加/
$target_path
$target_path = "/photo/";
因此,变量 $target_path
正在获取
上传的文件名。
您正在创建这样的路径:
/photoTheFileName.ext
这有两个问题:
首先,目录名和文件名之间没有/
。
当你解决这个问题时:
$target_path = "/photo/";
则路径为文件系统路径,将从文件系统的root开始。
你说:
upload.php file is in the same folder wher my Photo directory is
因此您希望目标路径类似于:
$target_path = "/hosts/www.example.com/htdocs/photo/";
…对您的文件系统进行适当的调整。
错误在第3行,你在目录名前加斜线,必须放在路径名后 $target_path="photo/";
<?php
$vdo=$_FILES['uf']['name']; $target_path = "photo/";
$target_path = $target_path . basename( $_FILES['uf']['name']);
$target_path . basename( $_FILES['uf']['name']);
if(move_uploaded_file($_FILES['uf']['tmp_name'], $target_path))
?>