正如标题所说,有人知道为什么图片没有上传吗?我正在尝试制作一个 propic 图片上传页面,但图片没有上传。
这是 HTML 表单:
<form enctype="multipart/form-data" method="POST" action="../php/modifica-profilo.php">
<!-- other inputs -->
<div class="form-group">
<label>Immagine profilo</label>
<input type="file" name="propic" class="form-control-file" accept="image/x-png,image/jpeg">
<small class="form-text text-muted">Solo immagini .png e .jpg - Dimensione massima 4 MB</small>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" type="submit" name="dettagliBtn">Salva modifiche</button>
</div>
这是 php 脚本部分“modifica-profilo.php”:
if(!empty($_POST['propic'])){
$dimensioneFile = $_FILES['propic']['size'];
$tipoFile = $_FILES['propic']['type'];
$tmp_name = $_FILES['propic']['tmp_name'];
$dir = "../img/propic-utenti/";
$estensione = image_type_to_extension(IMAGETYPE_PNG);
$estensione = image_type_to_extension(IMAGETYPE_JPEG);
$propic = md5($uid).$estensione;
if($dimensioneFile > 4000000){
echo "Il file è troppo grande";
}else{
move_uploaded_file($tmp_name,$dir.$propic);
}
}else{
$prendoPropic = "SELECT propic FROM clienti WHERE id='$uid';";
$rpp = $conn->query($prendoPropic);
$p = $rpp->fetch_assoc();
if($p['propic'] == "p-default.png"){
$propic = "p-default.png";
}else{
$propic = $p['propic'];
}
}
$aggiornodb = "UPDATE clienti SET cognome='$cognome', nome='$nome', email='$email', propic='$propic' WHERE id='$uid';";
$risultato = $conn->query($aggiornodb);
子衿沉夜