Take photos and upload them to a remote server

I guess we need to understand more about what is going on here:

image

What kind of server?
What is the full url?
Have you checked the path provided in "global img1" ?
Why are you using PUT ? (instead of POST...)
Can you "POST" a file using curl/postman ?

Here is an example using php....

Thanks for the reply.

  1. the server is on siteground
  2. the complete url where I want to save the images is https://mysite/images/upload.php
  3. the path of the "img1" is file://storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Pictures/app_inventor_1683803670695.jpg
  4. I changed to POST

What is the response content in the Web.GotText event?

Taifun

none, an "error 1109: the specified url is not valid " notification comes out first

but url is correct, if I try to open url via browser it gives me a message that I set

Can you please show your upload.php file contents....

<?php
// Simple PHP script to save image file.
$imgDir = "images/";
$fileName = $_REQUEST['fname'];
$data = file_get_contents('php://input');
$store = file_put_contents($imgDir.$fileName, $data);
if  ($store !== false ) {
echo "File $fileName saved to server, $store bytes\n";
} else {
echo "File $fileName not saved\n";
}
?>

OK you are using the same php file as in my guide.

I notice you are supplying a full path as the image filename in the web url. You need to change this to just the filename. (see my guide)

Also try your url with curl or postman to test it. (see my guide)

hello, sorry if I reply late, I did as you told me, but I always get "error 1109", actually the url is correct
"https://mysite.com/images/upload.php?fname=app_inventor_1118989.jpg


Immagine

You are POSTing, so you cannot upload like that in a browser...

I'm sorry but I'm a beginner, can you help me?

Here an example:

Thanks for the reply, so I have to take the picture and then attach it? I would like to take the photo and send it directly

image

Looks like you have your upload.php inside the images directory. It should be in the next directory up. (See my guide, again....)

do you mean like this?
Immagine

Error code 400

Yes. You changed your script from the one above. Makes it difficult to help.....

Have you tested with a curl command yet?

ok i brought it back as it was before

You need to set the web1.url block...

Hi, sorry if I reply late, I solved it following the example proposed by Juan_Antonio, Thank you all, you have been very kind

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