[英]PHP : Joomla:- File upload issue issue in “iPhone devices” (Uploading the same image from different file upload fields) while working fine on desktop
[英]PhP File Uploading not working, fine until upload
我已經在為php上傳這個文件上工作了一段時間,但我無法使其正常工作。 當我單擊上載時,“ if”語句變為false。
如果有人可以指出我要去哪里,那太好了。
<?php
$name = $_FILES["file"]["name"];
$tmp_name = $_FILES["file"]["tmp_name"];
if(isset($name)) {
if(!empty($name)) {
$location = "uploads/";
if(move_uploaded_file($tmp_name, $location . $name)) {
echo "Uploaded";
} else {
echo $location . $name;
echo "<br>";
echo $tmp_name;
}
} else {
echo "Please choose a file!";
}
}
?>
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file"><br><br>
<input type="submit" value="Submit">
</form>
您的$ locatIon可能是錯誤的,請嘗試傳遞絕對路徑(示例中的路徑是相對於當前工作目錄的,並且可能不可寫)
這樣有效
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form action="getfile.php" method="post"><br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>
</body>
</html>
getfile.php
<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
"../uploads/{$_FILES['uploadFile'] ['name']}")
?>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.