Langsung ke konten utama

Postingan

Menampilkan postingan dengan label Image Upload

Upload File to Server using Retrofit in Android

Hello friends, In this post, I will show you how to upload Image/Video/Any Files to the Server in Android using Retrofit 2. In Retrofit 2 Image or any type of files will be uploaded as Multipart. The File is received using php. This Code is Updated with Multiple File Upload. Upload Single File Web Part: Create a PHP file named as upload_image.php and paste the following lines. <?php $target_dir = "uploads/"; $target_file_name = $target_dir .basename($_FILES["file"]["name"]); $response = array(); // Check if image file is a actual image or fake image if (isset($_FILES["file"])) { if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file_name)) { $success = true; $message = "Successfully Uploaded"; } else { $success = false; $message = "Error while uploading"; } } else { $success = false; $message = "Required Field Missing"; } $response[...