[英]PHP Upload using Post method
I was wondering if anyone could help me figure out how to add the following我想知道是否有人可以帮助我弄清楚如何添加以下内容
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Manual file upload</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="area">
<form enctype="multipart/form-data" action="index.php" method="POST">
<p>Upload your file</p>
<input class="button1" type="file" multiple="multiple" name="uploaded_file"></input><br/>
<input class="button2" type="submit" value="Upload"></input>
</form>
</div>
<?PHP
if(!empty($_FILES['uploaded_file']))
{
$path = "uploads/";
$path = $path . basename( $_FILES['uploaded_file']['name']);
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
echo "Uploaded to: " . "loclahost/site/uploads/" . $_FILES['uploaded_file']["name"];
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
</body>
</html>
you just need to add select box in it.您只需要在其中添加 select 框。 for ex.
例如。
<select name="folder_name">
<option value="upload">Uploads</option>
<option value="upload1">Uploads 1</option>
<option value="upload2">Uploads 2</option>
</select>
in php:在 php 中:
$path = $_POST['folder_name']; // instead of static - $path = "uploads/";
on every file uploading you can change the path if not it will select the default value of select box.在每个文件上传时,您可以更改路径,如果不是,它将 select select 框的默认值。 you can change the name of the folder as your need.
您可以根据需要更改文件夹的名称。 I think this will solve your problem.
我认为这将解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.