how can i show uploaded image?

A

anujv73

Hi everyone,
I wanted to show uploaded image to my page without saving it .Is it
possible to change image src to hard disk dir ? or is it uploaded
some tmp dir from where i can show my image to website. pls help me.
 
E

Erwin Moller

anujv73 schreef:
Hi everyone,
I wanted to show uploaded image to my page without saving it .Is it
possible to change image src to hard disk dir ? or is it uploaded
some tmp dir from where i can show my image to website. pls help me.

Hi,

Allthough many in here WANT to help you, it is quite hard to actually do
so based on what you posted.
A few questions:

1) 'Uploaded images': Where do they go? Do you save them on the server?
If so: You should know where.

2) You say 'my page'. What is that? Some HTML document on the server? Or
is it a script (eg PHP)? If the latter, you can scan the directory where
you stored your uploaded images and use them in the source HTML your
script sends back to the client.

3) 'Uploaded to some temp dir': Again: How the *censored* can we know
where and how you store your uploaded images?

Last: Javascript is NOT involved in uploading images, unless you happen
to use javascript as a serverside language, which I doubt based on posting.

Please, do yourself a favor, and write better questions.

Regards,
Erwin Moller

--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
 
E

Erik Reppen

Hi everyone,
I wanted to show uploaded image to my page without saving it .Is it
possible to change image  src to hard disk dir ? or is it uploaded
some tmp dir from where i can show my image to website. pls help me.

You can point to files anywhere on your HD you want if the page is
also coming from your local HD. If you're not serving the page from
your computer somehow, however (i.e. making it live on the internet),
you won't see them. Just look at the directory syntax to follow in the
address bar when you load html locally to figure it out. If you're not
sure what I mean by directories, I'm talking about folders. Look up
relative vs. absolute paths and accessing directories if you were
confused on that point.
 
B

Bart Van der Donck

anujv73 said:
I wanted to show uploaded image to my page without saving it. Is it
possible to change image src to hard disk dir ? or is it uploaded
some tmp dir from where i can show my image to website.

<script type="text/javascript">
function showit() {
document.getElementById('myshow').innerHTML =
'<img src="'
+ document.forms[0].myfile.value
+ '" alt="" border="0">';
}
</script>
<form method="post" action="#"
enctype="multipart/form-data" onSubmit="return false;">
<input type="file" name="myfile">
<input type="button" value="show" onClick="showit();">
</form>
<div id="myshow">&nbsp;</div>

If you would perform the upload, then the path of the file on the
user's computer is always present in the posted data. The manual of
your preferred server language should mention how to approach it (e.g.
PHP's $_FILES).

Hope this helps,
 
S

SAM

Le 9/1/09 9:59 AM, Bart Van der Donck a écrit :
anujv73 said:
I wanted to show uploaded image to my page without saving it. Is it
possible to change image src to hard disk dir ? or is it uploaded
some tmp dir from where i can show my image to website.

<script type="text/javascript">
function showit() {
document.getElementById('myshow').innerHTML =
'<img src="'
+ document.forms[0].myfile.value

For having tried a long time ago and more recently, this value depends
of the navigator. The recent ones do not more communicate it.
My iCab.3, Fx.3, opera.9 gave only the name of the file

In all cases (old navigators prefered) that can only work in local.
From the time you load this code on the Net it will give an error, at
least with old Fx.

At this time and for me :
- Fx.3.02 / Opera.9.6 : don't move, nothing happens
(they only give the name of the file)
- Safari.3 / iCab.4 : OK
 
B

Bart Van der Donck

SAM said:
Le 9/1/09 9:59 AM, Bart Van der Donck a écrit :
anujv73 wrote:
  <script type="text/javascript">
   function showit()  {
     document.getElementById('myshow').innerHTML =
                          '<img src="'
                          + document.forms[0].myfile.value

For having tried a long time ago and more recently, this value depends
of the navigator. The recent ones do not more communicate it.
My iCab.3, Fx.3, opera.9 gave only the name of the file

In all cases (old navigators prefered) that can only work in local.
 From the time you load this code on the Net it will give an error, at
least with old Fx.

At this time and for me :
- Fx.3.02 / Opera.9.6 : don't move, nothing happens
                         (they only give the name of the file)
- Safari.3 / iCab.4 : OK
                          + '" alt="" border="0">';
   }
  </script>
  <form method="post" action="#"
   enctype="multipart/form-data" onSubmit="return false;">
  <input type="file" name="myfile">
  <input type="button" value="show" onClick="showit();">
  </form>
  <div id="myshow">&nbsp;</div>

You're right - it seems I was a bit too quick with my conclusion.
 
J

jeff

anujv73 said:
Hi everyone,
I wanted to show uploaded image to my page without saving it .Is it
possible to change image src to hard disk dir ? or is it uploaded
some tmp dir from where i can show my image to website. pls help me.

I wrote something like this years ago, a few notes from my notes:

var image_path=form_ref.value; // get the form field value any way you want
image_path=image_path.replace(/ /g,'%20'); // fix spaces
image_path=image_path.replace(/^\//,''); // not sure I'm getting rid of
the starting slash

full_image_path = 'file:///'+image_path;

Then you just do anything you want when you have the path relative to
the computer (like: some_element_ref.innerHTML = '<img src="' +
full_image_path + '">'). I believe this works on PCs and Macs, no
warranty implied ;)

Jeff
 
T

Thomas 'PointedEars' Lahn

jeff said:
I wrote something like this years ago, a few notes from my notes:

But years ago, Web browsers had a lot more security leaks than they have
today. Remember the guy who could read your unencrypted back account login
information from a text file on your hard disk through a hidden (i)frame
when you happened to visit his Web site with script support enabled?
var image_path=form_ref.value; // get the form field value any way you want

These days, the `value' property of an HTML file input control will not
yield the full path, but only the filename (confirmed for Firefox 3.5.3 on
Windows XP SP3), if that.
image_path=image_path.replace(/ /g,'%20'); // fix spaces
image_path=image_path.replace(/^\//,''); // not sure I'm getting rid of
the starting slash

I don't follow; why were/are you not sure? Anyhow, there will only be a
starting slash in one of the Unices (including Mac OS X) or a deliberately
hacked FAT/NTFS), of course.
full_image_path = 'file:///'+image_path;

Because of the above, this will most certainly not work anymore.
Then you just do anything you want when you have the path relative to
the computer (like: some_element_ref.innerHTML = '<img src="' +
full_image_path + '">'). I believe this works on PCs and Macs, no
warranty implied ;)

Neither will this, except in a privileged environment (or one where the user
was stup^Wuninformed enough to lower their default security settings).

Nice try, though.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top