Upload Image to PC Server Error (No File Uploaded)

Hi guys, i have a problem while making an app to upload images from my phone to my pc server, so i already set up my server using XAMPP and set up img folder with path htdocs/graphicmobile/uploadimg, i alreeady have php file to upload in this server

this is my uploadimg.php

<?php

$upload_dir = __DIR__ . "/";

file_put_contents('debug_log.txt', "Request Method: " . $_SERVER['REQUEST_METHOD'] . "\n", FILE_APPEND);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    file_put_contents('debug_log.txt', "FILES: " . print_r($_FILES, true) . "\n", FILE_APPEND);

    if (isset($_FILES['image'])) {
        $file = $_FILES['image'];

        if ($file['error'] !== UPLOAD_ERR_OK) {
            echo json_encode(['status' => 'error', 'message' => 'File upload error: ' . $file['error']]);
            exit;
        }

        $filename = uniqid() . "_" . basename($file['name']);
        $target_file = $upload_dir . $filename;

        if (move_uploaded_file($file['tmp_name'], $target_file)) {
            $file_url = "http://" . $_SERVER['HTTP_HOST'] . "/graphicmobile/uploadimg/" . $filename;
            echo json_encode(['status' => 'success', 'file_path' => $file_url]);
        } else {
            echo json_encode(['status' => 'error', 'message' => 'Failed to move uploaded file.']);
        }
    } else {
        echo json_encode(['status' => 'error', 'message' => 'No file uploaded.']);
    }
} else {
    echo json_encode(['status' => 'error', 'message' => 'Invalid request method.']);
}
?>

this is my block

blocks

my .aia
uploadImgToServer.aia (98.7 KB)

my issue is the image cannot uploaded in pc server, in the texbox it return "no file uploaded"
I already try making HTML page to upload image using my uploadimg.php in laptop and my phone and its working properly the image send to pc server and return path file in pc server, but if i doing it in mit app inventor it cannot send the image
I need help from masters here

Thanks

Simplify ?

its working TIMAI2 thankyou so much sir

can i ask 1 more question? what if i want to upload more than 1 image ?

If you do not want to change anything server side, you can queue them up on your device, in a list, then iterate over that list and upload them one after another.

okay let me try this, thank you sir TIM2AI

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.