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

2 vues (au cours des 30 derniers jours)
Elias Hossain
Elias Hossain le 25 Mai 2017
Commenté : Elias Hossain le 25 Mai 2017
%%%% 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 commentaire
Elias Hossain
Elias Hossain le 25 Mai 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.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by