Page 1 of 1

How do I upload images?

Posted: Wed Oct 21, 2020 4:55 pm
by AMpos
I want to make a web-program where an user click a button, choose an image and it is uploaded to a server/web/cloud. Just one per click.

Something like "Welcome! Press HERE to upload a photo!"

Where I am lost is about the upload process itself, how to do it.

Later, another program (an .exe on a computer) will check the web/cloud/server for new photos uploaded and download them, but first I have to solve the upload :)

Re: How do I upload images?

Posted: Wed Oct 21, 2020 5:28 pm
by munfraid
Hi,

you need two codes, one for the client and one for the server.

For the client side you can find sample codes for SB here in the forums, for example this:
viewtopic.php?f=9&t=1929

For the server side to store the uploaded file you could use a simple php script. This is not too difficult. Have a look here:
https://www.w3schools.com/php/php_file_upload.asp

Re: How do I upload images?

Posted: Thu Oct 22, 2020 12:27 am
by AMpos
Thank you for the help.

With the w3school example, I have been able to upload photos.

I have tried the example at viewtopic.php?f=9&t=1929 but the SpideBasic program seems to sent an empty string to upload.php file

Any hint/help?

Re: How do I upload images?

Posted: Thu Oct 22, 2020 7:49 am
by Peter
AMpos wrote:With the w3school example, I have been able to upload photos.

I have tried the example at viewtopic.php?f=9&t=1929 but the SpideBasic program seems to sent an empty string to upload.php file

Any hint/help?
changing this line

Code: Select all

! formData.append('file', v_filetoupload);
to

Code: Select all

! formData.append('fileToUpload', v_filetoupload);
should help.

P.S.: there is no reason to post your questions in two threads at the same time

Re: How do I upload images?

Posted: Thu Oct 22, 2020 8:13 pm
by AMpos
I love you! :P it works

Re: How do I upload images?

Posted: Sat Oct 24, 2020 12:08 am
by AMpos
So, as SpiderBasic code I am using the code from

viewtopic.php?f=9&t=1929

and as upload.php the one from

https://www.w3schools.com/php/php_file_upload.asp

Is there a way to know if the file was uploaded or not, from SpiderBasic?

Re: How do I upload images?

Posted: Sat Oct 24, 2020 2:02 pm
by Peter
AMpos wrote:Is there a way to know if the file was uploaded or not, from SpiderBasic?
take a look at the UploadFileCallback() in my code.