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.
How can i upload image to a php server using MATLAB programmatically ?
2 views (last 30 days)
Show older comments
%%%% 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");
?>
Answers (0)
See Also
Categories
Find more on Web Services in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!