How can i upload image to a php server using MATLAB programmatically ?

2 views (last 30 days)
%%%% Here is the MATLAB code
data = imread('loading.jpg');
%imshow(data);
url = 'https://teamextreme.000webhostapp.com/AndroidFileUpload/fileUpload.php';
webwrite(url,data);
///// Here is fileUpload.php
<?php
echo
$_FILES['image']['name'] .
'<br/>';
$target_path = "uploads/";
$target_path = $target_path . basename($_FILES['image']['name']);
try {
//throw exception if can't move the file
if (!move_uploaded_file($_FILES['image']['tmp_name'], $target_path))
{
throw new Exception('Could not move file');
}
echo "The file " . basename($_FILES['image']['name']) . " has been uploaded";
} catch (Exception $e) {
die('File did not upload: ' . $e->getMessage()); }
rename($target_path,"uploads/test.jpg");
?>
  1 Comment
Elias Hossain
Elias Hossain on 25 May 2017
I don't know why is it not working.The error is: Error using webwrite (line 126) The media type 'application/x-www-form-urlencoded' is not permissible for numeric or logical data.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!