472,338 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

How to show preview of uploaded files from server

Hi all...

I have file upload option in my web application. I use Struts 2.
I wanted to show a preview of the uploaded file to the user.
The uploaded file can be of any type like Image(png,jpeg,gif,etc.),
PDF,doc,txt,ppt,xls,html,etc.

As of now the user has to download the file if he wants to see it which is
not a good idea.

By "preview" I mean, only the first page of the file if its a normal txt or pdf file
and the image in small size(may be a thumbnail) if its an image file.

It would be OK even if its not possible for other files than
image files. Preview(thumbnail size) for only image files would also be
OK, but atleast for image files that the user uploads, I have to show
the preview to user.

Hope you got the idea. Looking for some help :)
Any help would be appreciated.

Thanks and regards,
Sandeep.
Jun 29 '09 #1
7 9253
nathj
938 Expert 512MB
Hi,

First up I don't know if there is a Java solution to this but surely after the upload has taken place you know where the file is and what it is called?

If you have that information then you can display the image in a container (say a DIV) ion the web page. This could all be done using AJAX so it be presented seamlessly to the user.

That's what I would do, this would work for image files but not for other file types.

That's the best solution I can think up for this problem.

Cheers
nathj
Jun 29 '09 #2
r035198x
13,262 8TB
The different file types you want to preview require approaches. e.g The images require you to create scaled down versions of the images while the .pdf files require you to read the pdf document and retrieve only the first page.
Jun 30 '09 #3
Hi...

Thanx a lot for your replies. I got a solution for that (showing images). Actually my problem was that i store uploaded files in one server and application in another. So whenever the image is to be shown, it has to be fetched from the file server. So I did it like for the src property of <img> tag
i gave a servlet URL which will output the image after fetching it as a byte stream from the file server. So I have the image on the page without even storing it on the app server and can be displayed in any size.

This is fine for images but for other file types I have to check. I hope there are some utilities available for getting the first 1 or 2 pages and create an image of it to show.

Thanks and Regards,
Sandeep.
Jun 30 '09 #4
JosAH
11,448 Expert 8TB
I'd take the following route: given a file type or extension a factory creates a PreviewBuilder. That builder spits out some html given a file of that specific type and an OutputStream (the destination of the html code). A DummyBuilder creates a "no preview available" preview and is created by the factory if it can't find a proper association. A simple interface does the rest ...

kind regards,

Jos
Jun 30 '09 #5
Hi..
Thanx a lot for the reply.
creating a preview or showing it was not a prob for me. The image file will be stored in a server for which there is no URL to give. So simply saying, there is nothing i can give for the src of the img tag on the jsp side.
So I am calling the web service which will get the image in bytes and then
I output that using the write() method of ImageIO. This web service will be called by a servlet of which the URL is given for the src of img tag.
And now I can show the image in any size.

But for other file types I have to get something. It should generate an image of the first page. Once this image is there I can display it easily as I am doing for image files now.

Thanks and regards
Sandeep.
Jul 1 '09 #6
HI all,

Are there any free third parties available for generating preview of files?

Thanks and Regards,
Sandeep.
Jul 4 '09 #7
maali07
1 Bit
Hi,

I have done the uploading part. Now I need to make the preview of any type of my uploaded file. And I need to put download button in that preview. If I click that it should download.

Can anyone help me on this..Coding part should be done in JAVA

Thank you in advance..
Apr 29 '21 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Martin S | last post by:
I have a form that sends data on to another page so that the user can preview it before it is inserted in a database table. The problem is that...
1
by: geradeaus | last post by:
Even if you upload an image partially with ftp software, you can still read the image. Only the image will be partially gray. So, can I determine...
13
by: | last post by:
Although this question does not belong in here, I hope someone help, as I do not know where to send it, but someone here might have come acros...
1
by: Murugavel | last post by:
Hi all, Now,we stored uploaded files into our webserver(where the place our site is running) by normal upload function ASP.NET ,but we brought a...
21
by: strutsng | last post by:
<input type="file"> only allows the user to browse for files. How about "browse for folder" dialog? Can html/javascript do that? I couldn't find...
3
by: Jeff S | last post by:
I'm enabling users to upload files to the server. I'd like to show them some indication of percent complete. How can this be done? Thanks!
1
by: Tarren | last post by:
Hi there: I have figured out how to take the uploaded file from the form input and save it into the database, but I am wondering (and looking for...
0
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE...
4
by: RedHair | last post by:
I'd like to set up a file system for the ASP.NET 2.0 application to store user-uploaded files, since the members are more than 100,000 people, the...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.