mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 14:52:04 +00:00
fix: percorso immagine in pagina gestione prodotti gestito incorrettamente
This commit is contained in:
@@ -33,15 +33,16 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['save'])) {
|
|||||||
$stock = $_POST['stock'];
|
$stock = $_POST['stock'];
|
||||||
|
|
||||||
// Gestione immagine
|
// Gestione immagine
|
||||||
$image_path = $_POST['current_image'];
|
$image_path = basename($_POST['current_image']);
|
||||||
if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
|
if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
|
||||||
$target_dir = "../img/";
|
$target_dir = "../img/";
|
||||||
$target_file = $target_dir . basename($_FILES["image"]["name"]);
|
$image_name = basename($_FILES["image"]["name"]);
|
||||||
|
$target_file = $target_dir . $image_name;
|
||||||
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
|
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
|
||||||
// Controlli base
|
// Controlli base
|
||||||
if (in_array($imageFileType, ['jpg', 'png', 'jpeg', 'gif'])) {
|
if (in_array($imageFileType, ['jpg', 'png', 'jpeg', 'gif'])) {
|
||||||
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
|
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
|
||||||
$image_path = "/img/" . basename($_FILES["image"]["name"]);
|
$image_path = $image_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,9 +162,10 @@ $stmt_prod->close();
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<img src="<?php echo htmlspecialchars($product['ImagePath']); ?>" alt="Immagine" style="max-width: 100px;"><br>
|
<?php $image_display = '/img/' . ltrim($product['ImagePath'], '/'); ?>
|
||||||
|
<img src="<?php echo htmlspecialchars($image_display); ?>" alt="Immagine" style="max-width: 100px;"><br>
|
||||||
<input type="file" name="image" accept="image/*">
|
<input type="file" name="image" accept="image/*">
|
||||||
<input type="hidden" name="current_image" value="<?php echo htmlspecialchars($product['ImagePath']); ?>"></td>
|
<input type="hidden" name="current_image" value="<?php echo htmlspecialchars(basename($product['ImagePath'])); ?>"></td>
|
||||||
<td><button type="submit" name="save">Salva</button></td>
|
<td><button type="submit" name="save">Salva</button></td>
|
||||||
</form>
|
</form>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user