Is there anyway to use the Imageshack API without PHP? - html

If I use the ImageShack API just in a form like this:
<form method="post" enctype="multipart/form-data" action="http://www.imageshack.us/upload_api.php">
<p><input type="file" name="fileupload"></p>
<p><input type="text" name="key" value="Your_Developer_Key"></p>
<p><input type="submit" value="Go"></p>
</form>
the browser gets taken to an XML doc, which has the image URL, but is no use because I'm no longer on my site. I've tried loading it in an iFrame and that works, but I can't access it because it's cross-domain.
A Http Post in jquery won't work because I can't send a file in it. I don't know any PHP so using that would take lots of time to learn & setup etc. Do I have any other options?

You mention you know Ruby on Rails.
Posting a file with Ruby is rather simple. See: Ruby: How to post a file via HTTP as multipart/form-data?

Related

How do I create a script for this?

I am trying to take 2 media files and merge them together to become 1 media file. The problem is that whenever I upload 2 files from my computer, nothing happens. Does anybody know what I am doing wrong?
<html>
<body>
<p><form action="/action_page.php"><label for="myfile"><font size="6"> Choose a file </font></label><input type="file" id="myfile" name="myfile"><br><br><output type="submit"</form></p>
<p><form action="/action_page.php"><label for="myfile"><font size="6"> Choose a file </font></label><input type="file" id="myfile" name="myfile"><br><br><output type="submit"</form></p>
<p><form method="get" action="file.doc"><label for="myfile"><button type="submit" onclick="window.open('file.doc')">Download!</button></form></p>
</body>
</html>
That's not how HTML forms work.
Your action parameter should point to a backend (PHP, NodeJs, C#, Java... the options are plentiful), and that backend will process what you've uploaded.
The best you could do right now to eliminate the requirement of a backend to handle your form inputs is to use some lib on your frontend to perform what you want (I'm sure there's some jQuery plugin that'd enable you to do so).

HTML Form Downloading Response of POST Request

I am trying to use an HTML form to execute a post request. I know that in general AJAX is probably a better way to go about this, but my use case is very simple and I have to upload a file in this form submission (which is really easy just using HTML forms). Anyways, everything works, but for some reason my browser is downloading the contents of my POST request response, which I do not want to happen. I want nothing to actually occur when I submit the post request other than the post request being sent out.
Here is the HTML portion of my code:
<form enctype="multipart/form-data" action="/action" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000"/>
<input type="text" name="email" id="email">
<input type="file" name="file" id="file" accept="image/*">
<input type="submit">
</form>
I am not sure that it is relevant, but I am using a Flask webserver and here is the response I am returning:
response = {"status": 200}
return Response(json.dumps(response), mimetype='applications/json')
The issue is that I keep having files downloaded from my browser with '{"status": 200}' in them.
Status : 200 indicates.
The request has succeeded.
So an OK status response is sent to the location, /action as you have mentioned in action="/action". So I'm guessing this is the view you wanted to send the POST request too.
I don't have the code for your /action view, but either :
This is not the view you intended to send it too.
It is the view you intended to send it too.
So if its not the correct view, what you can do is, use jinja templating and mention your view like this.
<form method="POST" action="{{url_for('xyz')}}">
Notice how I use the url_for() in jinja templating to specify route.
And if its the correct view, i can answer the question by seeing your code for the view called action.
Most likely what could be wrong though is,
your return function is erroneous. Check the return function again.

How to send a post request to GTMetrix

I want my users to write his website on my site and then be sent to gtmetrix.com to start a new test, but without needing to write his website again.
I am trying with this:
<form method="post" action="https://gtmetrix.com/analyze.html">
<input type="text" placeholder="Enter your Website URL"></input>
<input type="submit">CHECK IT</input>
</form>
But i get a
Analysis Error
You tried to analyze an invalid/malformed URL
What i am doing wrong? is possible to do this?
It seems they require the url in the form data field called url.
You must use the following input tag:
<input type="url" name="url" value="" placeholder="Enter your website URL" maxlength="1024" autofocus="" required="">
Also, they could be blocking external referrers. But first try adding the name attribute.
First of all, I don't know if that website allows you to submit that form from external websites. Make sure that's possible!
Seccond of all, you are trying to sent a form without setting the name of the input field. The resource that receives your request don't know anything to do with it.
If you want to analyse websites on your own website, search for services that provide APIs for using it external.
I am not familiar with gtmetrix, but you need to set the name attribute on your input to send it with the request.

How do I make a simple email form submission in HTML?

I tried w3schools but it didn't help and I tried other websites too. I just wanna make a short html script that sends an email to an email address, but I keep reloading my email inbox and nothing comes up. Can you help?
<form action="MAILTO:MY_EMAIL#yahoo.com" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">
<input value="Submit" type="submit">
</form>
You need to use a server side script here. HTML alone won't help you here. HTML is just the frontend logic. You need some script on backend that accepts this data you submit and actually sends out an email. To take the example in PHP, assuming u have the server set up and all or that your shared
<form action="sendmail.php" method="post" enctype="text/plain">
<input type="text" name="email" value="Email">
<input type="text" name="message" value="Message">
<input value="Submit" type="submit">
</form>
sendmail.php
$email=$_POST['email'];
$message=json_encode($_POST);
$receiver="MY_EMAIL#yahoo.com";
$mailer="mailer#myservice.com";
mail($email,"Message for enquiry or whatever",$message, array("from"=>$mailer));
There were, at some point, browsers that supported forms of this type. However, they're all gone now -- you will need a server-side script to send email. It's impossible to do using HTML alone.
You are confusing a few things.
When you Submit a form, it goes from the client (browser) to your server, which acts upon it. The form action needs to be a URL which handles the request. The mailto: URI scheme is not a valid action to use.
You have two choices:
You can create a mailto: link like this:
Send email
which will open your default email client,
OR
You can put a URL corresponding to an end point on your server, something like
form action="/send/mail"...
and have your server send the email
I believe the easiest way to do this is using a service like Zapier or IFTTT. Both of them offer a way to create Zaps/Applets that can send an email when you post to a specific url.
This is what configuration would look like in IFTTT and Zapier .
IFTTT is simpler to setup, Zapier has more options, like sending to more than one emails. I believe IFTTT only lets you send to your account's email.

Using <input type="file"> in Django

When someone clicks Submit after selecting a file with the <input type="file"> element, how do I access the contents of the file in Django?
(It seems like the request sent to the request handler has no trace of the file anywhere -- not even in request.FILES.)
Currently my template is like:
<form method="post" enctype="multipart/form-data">
<input type="file" enctype="multipart/form-data" name="file" accept="text/csv"/>
<input type="submit" value="Upload" />
</form>
View:
def HandleRequest(request):
print "**** request:", request
I don't see anything being printed about the file.
Note:
There's probably other ways to do this in Django, but I'm looking a solution using the simple input tag, and not something else (which would probably involve Javascript).
The code you posted, as it is posted, works fine. The HTML is sound (though I think the enctype on the <input> is redundant at best), and a very simple view shows an InMemoryFile after the POST. The problem must lie in something between the browser and your view. Some things to check:
Middleware.
Apache.
Nginx.
Decorators on your view.
mod_wsgi configuration.