我对PHP很陌生,所以请耐心等待。我有一个问题,我需要能够以3种不同的尺寸上传相同的图像。现在,我真的只知道如何一次上传一个图像(见下图),并希望能够通过某种方式使用我已经创建的代码(因为我理解)。如果那是不可能的,我愿意接受建议:)。
上传表单HTML:
<form action ="" method="post" enctype="multipart/form-data">
<input type="file" name="upload_file">
<input type="submit" name="submit_file" value="Upload">
</form>
上传代码PHP:
if (isset($_POST['submit_file']))
{
$file = $_FILES['uploadet_file'];
if($file['error'] == 0)
{
$new_filename = time() . "_" . $file['name'];
$new_map = "img/" . $new_filename;
move_uploaded_file($file['tmp_name'],$new_map);
$dbcon = mysqli_connect("localhost", "root", "", "databasename");
$query = mysqli_query($dbcon, "INSERT INTO uploaded_images (image_id, image_map, image_name) VALUES (image_id, '$new_map', '$new_filename')");
}
else
{
echo "<p>File was not uploaded correctly</p>";
}
}
希望你能帮助我。 :)