473,789 Members | 2,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to upload an <img> content without <input type=file > ?

Hi all,

I wonder is it possible to upload the content of an <imgfield to a server.
The content of the <imgwas downloaded from a web site different from the
one it should be uploaded. The image file should not be saved locally before
uploading. It should not be visible any <input type=file on the form.
How can it be done?

I'm working on a project where client javascript requests an image server to
generate dynamic images. The client selects the image it wants and uploads
this to another server which stores the image. I know it is very simple to
upload a file to a server by using <input type=file but it is not the
case. The image I need to uploaded is stored on a <img field and is not
saved to local file system.

Any hint is welcomed
Thanks in advance
Sammy
Jan 12 '07 #1
4 9088
Rik
SammyBar wrote:
Hi all,

I wonder is it possible to upload the content of an <imgfield to a
server. The content of the <imgwas downloaded from a web site
different from the one it should be uploaded. The image file should
not be saved locally before uploading. It should not be visible any
<input type=file on the form.
How can it be done?

I'm working on a project where client javascript requests an image
server to generate dynamic images. The client selects the image it
wants and uploads this to another server which stores the image. I
know it is very simple to upload a file to a server by using <input
type=file but it is not the case. The image I need to uploaded is
stored on a <img field and is not saved to local file system.

Any hint is welcomed
Thanks in advance
Well, if the file 'should not be saved locally' and 'was downloaded from a
website' (which is a contradiction btw), I assume passing the url of the
image file to a server side script should suffice. Do this in either a text
or a hidden <input>. As long as the image file is online somewhere
retrieving and manipulating it is a piece of cake for most server side
languages.
--
Rik Wasmus
Jan 12 '07 #2
Interesting request. I'd say you need to research two things first.
Read through the RFC that covers how the file upload control works
(http://www.ietf.org/rfc/rfc1867.txt), and maybe the w3c mention of it
(http://www.w3.org/TR/html4/interact/forms.html). After that consider
setting up a test upload form and receiving script on your server,
sniff your connection using ethereal or similar, and do an upload. This
should give you a solid understanding of what exactly the server
expects.

Now I'll take a theoretical stab at a solution. AFAIK there is now way
in javascript to access that actual image raster data, just properties
of the img element such as src. What I think might work is this:

1. When the user selects the image they want, get the url of it in JS
via the src property.
2. Dispatch a request using AJAX to the server for that image. This is
where it starts to get tricky since the server will respond with raw
image data (JPG/PNG/GIF) and the corresponding MIME type, and as such
the browser will probably not populate either the responseText or
responseXML. However you may be able to access the image data via
responseBody property - I'm not sure.
The other alternative here is to have the server serve images
indirectly through a script (that reads and dumps the image data). The
server script could search for a certain header, which your AJAX
request would have to set, and when it sees that header, dump the image
data as a base64 encoded string and use text/plain as the MIME type.
When your xmlhttp object gets a response, it will have the base64
encoded image in the responseText property, which you can then post to
the server as a normal form (that is, without the
enctype="multip art/form-data").
3. The server receiving the posted image data will need to know that
its receiving base64 image data, so you'd need to set some headers in
your AJAX post. The server would then know to decode the string back to
it's original binary format - the image.

Let me know how you progress with this - if I ever get a break i may
have to take a crack at it.

SammyBar wrote:
Hi all,

I wonder is it possible to upload the content of an <imgfield to a server.
The content of the <imgwas downloaded from a web site different from the
one it should be uploaded. The image file should not be saved locally before
uploading. It should not be visible any <input type=file on the form.
How can it be done?

I'm working on a project where client javascript requests an image server to
generate dynamic images. The client selects the image it wants and uploads
this to another server which stores the image. I know it is very simple to
upload a file to a server by using <input type=file but it is not the
case. The image I need to uploaded is stored on a <img field and is not
saved to local file system.

Any hint is welcomed
Thanks in advance
Sammy
Jan 12 '07 #3
So I just read Rik's response, which showed how complicated an answer
mine was to a simple problem. Do what he said: communicate the URL of
the image from one server to the other, and let the server receiving
the url download it directly. Forget the forms bit - just tell the
server the url of the desired img.

Rik wrote:
SammyBar wrote:
Hi all,

I wonder is it possible to upload the content of an <imgfield to a
server. The content of the <imgwas downloaded from a web site
different from the one it should be uploaded. The image file should
not be saved locally before uploading. It should not be visible any
<input type=file on the form.
How can it be done?

I'm working on a project where client javascript requests an image
server to generate dynamic images. The client selects the image it
wants and uploads this to another server which stores the image. I
know it is very simple to upload a file to a server by using <input
type=file but it is not the case. The image I need to uploaded is
stored on a <img field and is not saved to local file system.

Any hint is welcomed
Thanks in advance

Well, if the file 'should not be saved locally' and 'was downloaded from a
website' (which is a contradiction btw), I assume passing the url of the
image file to a server side script should suffice. Do this in either a text
or a hidden <input>. As long as the image file is online somewhere
retrieving and manipulating it is a piece of cake for most server side
languages.
--
Rik Wasmus
Jan 12 '07 #4
SammyBar said the following on 1/12/2007 9:54 AM:
Hi all,

I wonder is it possible to upload the content of an <imgfield to a server.
The content of the <imgwas downloaded from a web site different from the
one it should be uploaded. The image file should not be saved locally before
uploading. It should not be visible any <input type=file on the form.
How can it be done?
You can't. The image is locally though in the cache as long as the
current page is open.
I'm working on a project where client javascript requests an image server to
generate dynamic images. The client selects the image it wants and uploads
this to another server which stores the image. I know it is very simple to
upload a file to a server by using <input type=file but it is not the
case. The image I need to uploaded is stored on a <img field and is not
saved to local file system.
It is not "saved" but it is in the cache. And you aren't going to be
able to set the value of a file input so you can't do it
programatically . The user is going to have to choose that image to be
uploaded.

If the images are random then you are kind of hosed. If the images are
dynamic yet predictable then you simply give your server the parameters
to get the image on its own.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
13087
by: Gregory | last post by:
Hello, I'm trying to do the above in order to process an image and return the result to an html image control. It fails and my key suspects are either the variable that I'm passing in - ImageName - for processing, or the return data which is done (or not as the case may be) by imagejpeg($img) in the script, after header("Content-type: image/jpeg"). Any insights would be most welcome, especially debugging techniques and a pointer to...
8
5157
by: slim | last post by:
hi again all, i am still working on the website as mentioned in earlier threads and have hit another snag... http://awash.demon.co.uk/index.php http://awash.demon.co.uk/vd.css the php is pulling a name and placing it under the thumbnail (the text is
2
5790
by: Kimmo R. M. Hovi | last post by:
Currently I have defined: -- clip clip -- <form method="post" action="xx" enctype="application/x-www-form-urlencoded"> <input type="image" name="Function 1" src="image1.gif" border="0" title="1">
8
67464
by: KS | last post by:
Just to show some code to show the consept. <img id="date" onclick="javascript:show_calendar();" src="/PlexSysWeb/images/show-calendar.gif" width=20 height=18 border=0> What i want the javascript to do is change the onclick value of the <IMG> tag above, by calling the test function from the same webpage by onclick on a button.
22
2547
by: David. E. Goble | last post by:
Hi All; I have a few of these; sigsImages="sigs/finished1.jpg" sigsImages="sigs/foghorn.jpg" lower I have;
2
1711
by: ThePsudo | last post by:
# SIMPLE VERSION # Is there a way I can create a new <img> tag onClick? # DETAILED VERSON # I'm making a game that involves drawing a path between two points on a grid. I've got the pathfinding routine working fine, but drawing it out on a grid is proving difficult. Since I can't just draw a line segment, I made a set of graphics to use: a bit of horizontal line, vertical line, and two diagonals. I just take a few copies of each and
10
3089
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page like it tried to do it but errored... I thought changeing the max size for the file input box to about 100mb would fix it but nope here is my page code and my code behind code... ===============
17
3211
by: Alan Silver | last post by:
Hello, I have a page which I am converting to use themes. The page has an HTML <input type="image"> element that is used to post to another page. I would like to replace this with a server control so I can add a skinid. I tried adding runat="server" and the skinid to the existing control, but that didn't work. Any other ideas? TIA --
3
21273
by: jackiepatti | last post by:
QUESTION: I have a web page containing a form that contains an image instead of a submit button, e.g. <form name='myform' action='get' method='otherpage.asp'> <input type='image' src='picture.gif' name='myimage' id='myimage'> </form> When forms with image types are submitted, the value is not returned; instead, when the form is submitted, the XY coordinates of the where the user clicked on the image are sent. For example, if the user
0
9665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.