簡體   English   中英

無法將文件上傳到服務器

[英]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))
?>

當我的Photo目錄對您有任何幫助時, upload.php文件位於同一文件夾中

您需要在/之后添加/

$target_path

$target_path = "/photo/";

因此,變量$target_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))
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM