How to upload a Photo and save it into website using Python Flask - pythonanywhere

I am having trouble allowing users to upload a photo into my website and have it save to a folder so that the photo could be used later on. My goal is to have my program guess the shape that was submitted.
I so far have the html code in which allows a user to upload a photo onto my website but when the user submits it, it goes no where.
HTML:
<div class="w3-third">
Your image: <input type="file" name="pic" id="pic"><br>
<input type="submit" value="Submit">

Related

Finding PayPal Buy Now Button redirection link

I am trying to make a program that can scrape a site and search for PayPal buy now button redirection links.
I can scrape the site but I realize that when you hit the button, it does not contain the URL that you will be redirected to make purchase. How would I go about finding the button redirection link, or even how would I have the site scrape and click on the button to at least have the redirect site appear? Would I somehow have to make the scraper hit the form and submit?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"><input name="cmd" type="hidden" value="_s-xclick" /><br />
<input name="hosted_button_id" type="hidden" value="PUEGWVJXLH4FQ" /><br />
<input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" type="image" /><br />
<img loading="lazy" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" /></form>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">_______________________________________________________</p>
</form>
Go to https://www.paypal.co/buttons, log in, and (after logging in) create a new simple Buy Now button with no dropdown options nor text fields (which require HTML) -- and once the button is created and you are viewing the generated code, switch over to the "E-mail" tab above it.
The link in that E-mail tab will have a hosted button ID, which you can swap out / use to dynamically generate the Buy Now "redirection link" you're asking for. When loaded in a browser, that link will initiate a checkout, same as clicking the button.
There are several other types of PayPal payment buttons, including:
Unhosted Buy Now buttons (which are not saved at PayPal, and do not have a hosted_button_id). These buttons use a redirection link or form post that will include HTML variables to set up the payment.
Newer smart buttons, generated via https://www.paypal.com/buttons/smart or similar -- these do not have redirection URL, and instead use JS to open a mini window for payment approval.
Another way to construct a working URL is to begin with the form's action parameter https://www.paypal.com/cgi-bin/webscr, add ? to begin a GET string, and add all the inputs from the form that have a name, in with the syntax name=value, separated by '&' .... so for example:
https://www.paypal.com/cgi-bin/webscr?hosted_button_id=PUEGWVJXLH4FQ&anothername=anothervalue&...

callback URL after succesfull Video post trough Facebook API graph

I'm starting to get my Facebook integration working on my own app but I'm still strugling with one part:
create a callback URL of redirect URL after a successful video post on my facebook wall trough:
<form enctype="multipart/form-data" action="https://graph-video.facebook.com/v2.9/me/videos?source={{video_source}}&access_token={{access_token}}="POST">
<input name="file" type="file" value="">
<input type="submit" value="Upload" />
</form>
Does anyone know how to do this. So after a successfull upload redirect to a page in my app.
Thanks for helping me out.

facebook share before download

I wish to set up a facebook share gate to access my files in my website. when the user shares my website on their facebook acct, they can download the file. otherwise, no. This question is pretty similar to the post below. I tried the demo provided by adam with the downloaded file link inserted to the code. But it failed. It just show the file without popping out the usual facebook share dialogue in my website. However, if i tried the demo there, it did pop out the share dialogue together with the file even before i share. Am I missing something in the code? as i just copy the code in the demo to my website. Thank you.
Is it possible to add a link to download a file that can only be downloaded by sharing it on Facebook?
`
<div>
<p>This file is locked, to unlock and download it, share it</p>
<p class="hidden">Thanks for sharing, the file is unlocked and ready for download</p>
<p class="hidden">In order to download this file, you need to share it</p>
</div>
<a class="fsl fsl-facebook" href="#" id="facebook-share">
<span class="fa-facebook fa-icons fa-lg"></span>
<span class="sc-label">Share on Facebook</span>
</a>
<a class="fsl content-download" href="http://img3.wikia.nocookie.net/__cb20140510200316/spiritanimals/images/0/05/Tiger.jpg" id="download-file">
<span class="fa-download fa-icons fa-lg"></span>
<span class="sc-label">Download File</span>
</a>
`
adam's demo code

upload files using XTRF REST API

I have tried a form submit with files example all the files are getting uploaded to XTRF and getting the response.
Now I am using blueimp jquery file uploader[http://blueimp.github.io/jQuery-File-Upload/]. If I upload image files it is getting uploaded to XTRF. If I upload any other files it is not getting uploaded to XTRF. I am getting workfile.rtf as response with junk data.
Please help me in solving this issue.
Need to upload files to XTRF using ajax uploader.
POST /system/session/files
Accepts files encoded as multipart/form-data and stores them temporarily (they are available only within current session). Each file gets its own id and basic statistics: number of characters (with and without spaces), words, lines, pages.
sample html form for file upload
<form id="upload" action="baseURL/system/session/files" method="post" enctype="multipart/form-data">
<label>Select a file:</label>
<input type="file" name="file" size="45"></input>
<input type="submit" value="Upload"></input>
</form>
You can also send plain text assigned to parameter content encoded as application/x-www-form-urlencoded. Such text will be stored as uploaded file.
sample html form that sends text for upload
<form id="sourceText" action="baseUrl/system/session/files" method="post" enctype="application/x-www-form-urlencoded">
<label>Source text:</label>
<textarea name="content" rows="5" columns="40"></textarea>
<input type="submit" value="Save"></input>
</form>
Uploaded files can be attached to quote request or while updating user's profile.

can you append form data to a URL in a phonegap webapp?

In my phonegap webapp, I have a form with some serious GET action on it. When I click submit, I want to open a new page and extract the form data from the URL with javascript.
Question: can you do that in a phonegap app, when you're not actually in a browser?
Yes, you can! It's as simple as I said:
<form action="destinationpage.html" action="GET>
Input your data:<input type="text" name="data /> <br />
<input type="submit" value ="Continue">
</form>
Then see the answer to this question for retrieving your data on the next page!