Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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 无法将文件上载到服务器_Php - Fatal编程技术网

Php 无法将文件上载到服务器

Php 无法将文件上载到服务器,php,Php,这是我上传文件的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

这是我上传文件的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\u路径

$target_path = "/photo/";
因此,变量
$target\u path
将文件夹名称前置到


文件名已上载。

您正在创建如下路径:

/photoTheFileName.ext
这有两个问题:

首先,目录名和文件名之间没有
/

当您修复该问题时:

$target_path = "/photo/";
然后路径就是文件系统路径,它将来自文件系统的根目录

你说:

upload.php文件与我的照片目录位于同一文件夹中

因此,您希望目标路径类似于:

$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))
?>

路径是否存在?路径是否具有正确的权限?