473,569 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to show preview of uploaded files from server

97 New Member
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(thumbna il 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 9515
nathj
938 Recognized Expert Contributor
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 MVP
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
sandeepk84
97 New Member
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 Recognized Expert MVP
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
sandeepk84
97 New Member
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
sandeepk84
97 New Member
HI all,

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

Thanks and Regards,
Sandeep.
Jul 4 '09 #7
maali07
1 New Member
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
1914
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 the form sends both text and possibly an image to the page used for preview. Even if I use a hidden input field for the image file it still is displayed on the text centric page but with enctype for...
1
2603
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 with a php-function if an image is fully uploaded on the server and without checking the filesize using an interval in time? To be completely clear : this isn't about http-upload, but about...
13
3028
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 similar problem: Some of JPG files sitting in the same folder show up OK on an HTML page, while the other do not as if they are not there or their name is misspelt. Tried low-upper case in an ASP...
1
1614
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 new server for keeping files. How Can we moving the uploaded files to other server (consider as FileServer) from our application Server(Web Server). Can any one give simple solution,
21
66782
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 any syntax for that. If not, please advise what are the other approaches. please advise. thanks!!
3
2032
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
2077
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 examples) how can I stream the image back to the browser directly from the form element (not saving to the db and pulling it back out) as the ImageURL for another web control so they can 'preview'...
0
1204
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 ********************** <%@ Page Language="VB" Debug="true" %>
4
2536
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 basic requirements are as below: (1) The file system is separate with front-end web site (2) Need to re-size user-uploaded image file to same size (3) Need to rename file name to avoid duplicate...
0
7703
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...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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...
1
5514
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...
0
5223
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...
0
3657
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...
1
2117
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
0
946
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...

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.