• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

image not shows full path

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i create a file type input button
when i upload a file from my pc it should be saved into mysql database
so i used this
request.getParameter("img");
then i insert it into database table

but when i open my table into MYSQL
i saw image name not full means it not show full path
what should i do now?

all over i want
when user signup and loads its photo
this photo must be displayed whenever he logins
 
Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think it is good idea to store absolute paths. What if you migrate your app to another server? It is better to use relative path which is relative to the working directory of the application.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you wanting to store the image itself in the database, or the file path on the file system? If you are using a file upload control you will not be able to use getParameter().

Please explain your requirements in better detail.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually i want that when user upload its image
it must be shown in his profile when he again login


for this we store it into database
how ?

i used getParameter but it not show full path
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read the JSP FAQ regarding file uploads. You cannot use getParameter() with a file upload.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And even if you could, it would be useless--it would be the path of the file on the *client* machine, not the server. And different browsers include different information in that path--some put the entire path (incorrect behavior), some just the filename. Save the file locally, save *that* path in the DB.
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the image is uploaded, it needs to be saved on the server somewhere. You can either save the image file in the file system, then save the path to that file in your database, or just save the image itself in the database (then you don't need to worry about the path at all).

Then you can use an Image Servlet (there an article in the ServletsFaq that talks about this) to serve the image on later requests.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am not understanding
what you want to say
can anyone give me link or code
so that i can understand the thing
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to upload a file, the form needs to have enctype="multipart/form-data".

In order to process such a form on the server side, it's easiest to use a library that handles parsing the request parameters, for example, the Apache Commons FileUpload library.

The filename sent with the form is the name of the file on the client--in other words, if I'm upload a file to your site, the filename sent by my browser will be the filename on *my* system. It may or may not include complete path information (again, on *my* machine)--that behavior depends on the browser. The name of the file on *my* machine is useless to you.

Your application, on the *server* side, should save the file locally. *That* filename, including the path, is what you should store in your database, and use an image servlet as previously mentioned to send it back to a client. I'm not a fan of storing the images themselves in the database.
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, this is all covered in the FAQ.
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic