How do I upload images?

Just starting out? Need help? Post your questions and find answers here.
AMpos
Posts: 42
Joined: Mon Aug 03, 2020 5:15 pm

How do I upload images?

Post 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 :)
munfraid
Posts: 104
Joined: Sat Mar 24, 2018 1:33 pm

Re: How do I upload images?

Post 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
AMpos
Posts: 42
Joined: Mon Aug 03, 2020 5:15 pm

Re: How do I upload images?

Post 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?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How do I upload images?

Post 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
AMpos
Posts: 42
Joined: Mon Aug 03, 2020 5:15 pm

Re: How do I upload images?

Post by AMpos »

I love you! :P it works
AMpos
Posts: 42
Joined: Mon Aug 03, 2020 5:15 pm

Re: How do I upload images?

Post 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?
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: How do I upload images?

Post 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.
Post Reply