Jump to content

Get image from POST method


Topphemelig

Recommended Posts

I am a C# programmer, and I'm working on a HTTP Server. I need to get an image from a POST method,here is the page so far:

<html>	<title>		CTP Server 2.0	</title>	<center>		<form method="POST">"			<input type="hidden" name="user_name" value="%USERNAME%">			<input type="hidden" name="password" value="%PASSWORD%">			<input type="hidden" name="action" value="view_screenshot">			<input type="submit" value="Refresh Screenshot">		</form>		<br>				<!-- Here i need the image, with the exact same POST values as above except the action should be "get_screenshot" -->	</center></html>

Hope this is enough information to help me,and thanks for any replies :)

Link to comment
Share on other sites

yes its possible, but you require server side scripting to retrieve the valuesphp example$imagevalue = $_POST['get_screenshot'];<img src="myimagefolder/<?php echo $imagevalue; ?>.jpg" />
My server receives this as a GET meathod, is it possible to do this as a POST method?
Link to comment
Share on other sites

Don't know if this is a typo or if its affecting your code at all but you have an extra quote:<form method="POST">" <-- Right here at the endAlso you need to have the action attribute in there. If it's submitting to itself (which it looks like it is) you can leave it blank, but it has to be there.<form action="" method="post">Other than that, if you set the method to post it should go through as a POST.

Link to comment
Share on other sites

Don't know if this is a typo or if its affecting your code at all but you have an extra quote:<form method="POST">" <-- Right here at the endAlso you need to have the action attribute in there. If it's submitting to itself (which it looks like it is) you can leave it blank, but it has to be there.<form action="" method="post">Other than that, if you set the method to post it should go through as a POST.
No, it's just the source code from my program, i have just forgot to remove that quote when i converted it into readable HTML code.Here is the source code from my server:
						byte[] r_content = Encoding.UTF8.GetBytes("<html>" + NEWLINE +							NEWLINE +							"\t<title>" + NEWLINE +							NEWLINE +							"\t\tCTP Server 2.0" + NEWLINE +							NEWLINE +							"\t</title>" + NEWLINE +							NEWLINE +							"\t<center>" + NEWLINE +							NEWLINE +							"\t\t<form method=\"POST\">" + NEWLINE +							NEWLINE +							"\t\t\t<input type=\"hidden\" name=\"user_name\" value=\"" + user_name + "\">" + NEWLINE +							NEWLINE +							"\t\t\t<input type=\"hidden\" name=\"password\" value=\"" + password + "\">" + NEWLINE +							NEWLINE +							"\t\t\t<input type=\"hidden\" name=\"action\" value=\"view_screenshot\">" + NEWLINE +							NEWLINE +							"\t\t\t<input type=\"submit\" value=\"Refresh Screenshot\">" + NEWLINE +							NEWLINE +							"\t\t</form>" + NEWLINE +							NEWLINE +							"\t\t<br>" + NEWLINE +							NEWLINE +							"\t\t<img src=\"myimagefolder/<?php echo $_POST['get_screenshot']; ?>.jpg\" />  " + NEWLINE +							NEWLINE +							"\t</center>" + NEWLINE +							NEWLINE +							"</html>");						byte[] r_header = get_header(r_content.Length, "text/html", "200 OK");						if (!client.Connected) { return; }						send_data(client, r_header);						if (!client.Connected) { return; }						send_data(client, r_content);

And here is the response from the server when it receives the data:

GET /myimagefolder/%3C?php%20echo%20$_POST[%27get_screenshot%27];%20?%3E.jpg HTTP/1.1Host: 192.168.0.193User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; nb-NO; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3Accept: image/png,image/*;q=0.8,*/*;q=0.5Accept-Language: nb,no;q=0.8,nn;q=0.6,en-us;q=0.4,en;q=0.2Accept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 115Connection: keep-aliveReferer: http://192.168.0.193/

As you see it's still a GET method by reading the 3 first letters. Since this server is password protected i can not show the password/usernamein the browser link bar.Is there any other way to send the data "hidden" without showing it in the borwser bar?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...