Home Answers Viewqa Java-Beginners upload and download video

 
 


haresh prajapati
upload and download video
4 Answer(s)      a year and 9 months ago
Posted in : Java Beginners

how to upload and download video in mysql databse using jsp? plz give me demo of this with table...

View Answers

September 23, 2011 at 4:33 PM


1)page.jsp

<%@ page language="java" %>
<Html>
<HEAD><TITLE>Display file upload form to the user</TITLE></HEAD>

<BODY>
<FORM ENCTYPE="multipart/form-data" ACTION="upload.jsp" METHOD=POST>
<br><br><br>
<center><table border="2" >
<tr><center><td colspan="2"><p align="center"><B>UPLOAD THE FILE</B><center></td></tr>
<tr><td><b>Choose the file To Upload:</b>
</td>
<td><INPUT NAME="file" TYPE="file"></td></tr>
<tr><td colspan="2">
<p align="right"><INPUT TYPE="submit" VALUE="Send File" ></p></td></tr>
<table>
</center>
</FORM>
</BODY>
</HTML>

2)upload.jsp

<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>

<%
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead,formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
out.println(saveFile);
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;

FileOutputStream fileOut = new FileOutputStream(saveFile);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();

%><Br><table border="2"><tr><td><b>You have successfully upload the file by the name of:</b>
<% out.println(saveFile);%></td></tr></table>
<%
Connection connection = null;
String connectionURL = "jdbc:mysql://192.168.10.112:3306/file";;;
ResultSet rs = null;
PreparedStatement psmnt = null;
FileInputStream fis;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
File f = new File(saveFile);
psmnt = connection.prepareStatement("insert into file(file_data) values(?)");
fis = new FileInputStream(f);
psmnt.setBinaryStream(1, (InputStream)fis, (int)(f.length()));
int s = psmnt.executeUpdate();
if(s>0) {
System.out.println("Uploaded successfully !");
}
else {
System.out.println("unsucessfull to upload file.");
}
}
catch(Exception e){e.printStackTrace();}
}
%> 
<a href="download.jsp">Download File</a>

September 23, 2011 at 4:47 PM


3)download.jsp:

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="javax.servlet.*"%>
<%
ServletOutputStream output = response.getOutputStream();
String connectionURL = "jdbc:mysql://192.168.10.112:3306/file";;;;;
String Content=new String("");
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection(connectionURL,"root","root");
Statement st=con.createStatement();
ResultSet rst= st.executeQuery("select * from file");
if(rst.last())
{
Content=rst.getString("file_data");
}
con.close();
}catch(Exception e){
System.out.println("Exception caught"+e.getMessage());
}
byte requestBytes[] = Content.getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(requestBytes);
response.reset();
response.setContentType("mime/flv");
response.setHeader("Content-disposition","attachment; filename=" +"file.flv");
byte[] buf = new byte[1024];
int len;
while ((len = bis.read(buf)) > 0){
output.write(buf, 0, len);
}
bis.close();
response.getOutputStream().flush();
%>

October 6, 2011 at 11:20 AM


thnx..


June 27, 2012 at 6:24 AM


Hello can anyone give the table for database for the above coding....PLZ









Related Pages:
upload and download video
upload and download video  how to upload and download video in mysql...;Display file upload form to the user</TITLE></HEAD> <BODY> <FORM...;center><td colspan="2"><p align="center"><B>UPLOAD THE FILE<
upload video
upload video  hi sir i want to code of upload and download video in mysql database using jsp... and plz give advice which data type is used to store video in table
upload video using php
upload video using php  How to upload a video on MYSQL Server using PHP Code..? Can any one provide me an example
Upload video app
Upload video app  Hi, How to create upload video application... should be able to take video from mobile phone b) User should be able upload the video on my server c) User should be able to save the video and then upload later
java/jsp code to download a video
java/jsp code to download a video  how can i download a video using jsp/servlet
upload and download mp3
upload and download mp3   code of upload and download Mp3 file in mysql database using jsp and plz mention which data type used to store mp3 file in mysql database
Upload and Download multiple files
Upload and Download multiple files  Hello Sir/Madam, I need a simple code for upload and download multiple files(it may be image,doc... link: http://www.roseindia.net/jsp/file_upload/uploadingMultipleFiles.shtml
Photo upload, Download
Photo upload, Download  Hi I am using NetBeans IDE for developing application for java(Swings). And i am using MySQL as backend database. My Problem is I have created JFrame form in NetBeans and i have inculded label in which i
file upload download - Java Beginners
file upload download  how to upload and download files from one system to another using java.io.* and java.net.* only please send me code
upload and download files - JSP-Servlet
upload and download files  HI!! how can I upload (more than 1 file) and download the files using jsp. Is any lib folders to be pasted? kindly... and download files in JSP visit to : http://www.roseindia.net/jsp/file_upload
Upload and Download in JSP - JSP-Servlet
Upload and Download in JSP  Respected Sir/Madam, I am... and downloading a file in JSP.. When the admin clicks upload, he must be able to upload files and similarly when the user clicks the download option, he must be able
upload and download a file - Java Beginners
upload and download a file  how to upload a file into project folder in eclipse and how to download the same using jsp   Hi Friend, Try the following code: 1)page.jsp: Display file upload form to the user
Video in flex
Video in flex  Hi........ I want to know What is the difference between streaming & progresive download? please give me an example for that.... Thanks in Advance
Upload and download file - JSP-Servlet
Upload and download file  What is JSP code to upload and download a document in a web page?  Hi Friend, Try the following code to upload the word document file: 1)page.jsp Display file upload form
how to upload and download images in java?
how to upload and download images in java?  what is the code....   Upload and Download images: 1)page.jsp: <%@ page language="java" %> <HTML> <HEAD><TITLE>Display file upload form
File Upload And download JSP Urgent - JSP-Servlet
File Upload And download JSP Urgent  Respected Sir/Madam, I... Download in JSP.. In the Admin window, There must be "Upload" provision where admin can upload files.. And in the user window, There must be a "Download" provision
java code to upload and download a file - Java Beginners
java code to upload and download a file  Is their any java code to upload a file and download a file from databse, My requirement is how can i... and Download visit to : http://www.roseindia.net/jsp/file_upload/index.shtml http
code to upload and download a file - Java Magazine
code to upload and download a file  Is their any code to upload a file and download a file from databse, My requirement is how can i store two... user send one a.doc file to x ,he has to download his a.doc another user sends
video uploading using jsp
video uploading using jsp  how to upload a videos in web page using jsp   Hi, You can upload your video with the help of JSP file upload code. Once file is upload you can play using any video player. Get the code
upload ,download and update file document - JDBC
upload ,download and update file document   hi sir.i am creating one application in jsp in which i need to upload the word document file which... to upload the word file: 1)page.jsp Display file upload form
video
video   I need code for creating video chatting in a webpage.Can you send me the code related to that or API
i want image upload and download useing STRUTS 1.2 version example..
i want image upload and download useing STRUTS 1.2 version example..  i am fresher of the developer..i want code for above title topic(i want image upload and download useing STRUTS 1.2 version example..)..plz send me code for my
video uploading using jsp
video uploading using jsp  this is the code i hv written..." value="Upload File"><br> </form></center> <...; private String email; private String video; FileItem fitem3
FileUpload and Download
coding for Upload and download file, but it is not stored in database and also it s not download the file with its content... just it download doc with 0 Bytes...; <HTML> <HEAD><TITLE>Display file upload form to the user<
FileUpload and Download
coding for Upload and download file, but it is not stored in database and also it s not download the file with its content... just it download doc with 0 Bytes...; <HTML> <HEAD><TITLE>Display file upload form to the user<
FileUpload and Download
coding for Upload and download file, but it is not stored in database and also it s not download the file with its content... just it download doc with 0 Bytes...; <HTML> <HEAD><TITLE>Display file upload form to the user<
FileUpload and Download
coding for Upload and download file, but it is not stored in database and also it s not download the file with its content... just it download doc with 0 Bytes...; <HTML> <HEAD><TITLE>Display file upload form to the user<
FileUpload and Download
coding for Upload and download file, but it is not stored in database and also it s not download the file with its content... just it download doc with 0 Bytes...; <HTML> <HEAD><TITLE>Display file upload form to the user<
FileUpload and Download
for File upload and Download in jsp using sql server,that uploaded file should... be download with its full content...can you please help me... im in urgent i have...;TITLE>Display file upload form to the user</TITLE></HEAD> <BODY>
upload and download all kinds of files in jsp - Java Beginners
upload and download all kinds of files in jsp  how to upload and download all kinds of files ex: image file,pdf,.xls in jsp. your help is highly appreciated.  we can upload the all type s of files into oracle 10g
Creat a folder, inside it upload and download files in jsp and mysql
Creat a folder, inside it upload and download files in jsp and mysql  Create one or more folder .inside it we can upload and download multiple files   Here is an application that will upload the file and save
J2ME Video Control Example
J2ME Video Control Example       This Application explain the use of Video Control. The work of video control is used to controls the display of video. In this example we
upload and download files from ftp server using servlet - Ajax
upload and download files from ftp server using servlet  Hi,Sir Sorry for my complex questions. My problem is that I don't know client side script for upload and download files from ftp server using servlet and how to use
HTML5 video poster image.
; Output: Download this codeDifference Between HTML5 and HTML4.01: The video...HTML5 video poster image. Introduction:The <video> tag supports many... the video tag. If you add image instead of video, then you use poster attribute
File Download in jsp
File Download in jsp  file upload code is working can u plz provide me file download
VoIP Video
VoIP Video          VoIP MSN Adds with Video Calls Microsoft launched the latest... features including full screen video calls, VoIP and shared search
Upload image
Upload image  Hai i beginner of Java ME i want code to capture QR...://video"); player.realize(); videoControl..._VIDEO, this); try
HTML5 video height width.
tag. </video > </body> </html> Output: Download...HTML5 video height width. Introduction:The <video> tag use for embedding video in a web page. It has many attribute. But in this tutorial, we
Struts Video Tutorials
Struts Video Tutorials - Now you can learn the Struts programming easily and in less time. Struts Video tutorials are very extensive and explained the concepts in great detail.In this section you will find the list of video tutorials
load and upload. - MobileApplications
load and upload.  Dear sir/mam, i want code for java based application, that can take .3GP video file and upload it to youtube using youtube's APIs. The video file would be located on a weblink (a direct http link to a video
HTML5 video element, Implementation of &lt;video&gt; tag.
. </video > </body> </html> Output: Download...HTML5 video element, Implementation of <video > tag. Introduction:The <video> tag is used for adding video or media file in HTML document
Uploading and download pdf or .txt file.
Uploading and download pdf or .txt file.  I want admin user to upload pdf file into database and the users can download those pdf format from database
Download
Download JDK  How to Download the latest Version of JDK?   Download OST to PST converter from: http://www.osttopst.info
upload using youtube api - MobileApplications
application, that can take .3GP video file and upload it to youtube using youtube's APIs. The video file would be located on a weblink (a direct http link to a video...upload using youtube api   sir, as u have asked for my
Video Tutorial: Installing WAMP Server
In this video tutorial I will explain you how to install WAMP Server and how you can download & installing WAMP Server on your windows system. You can... you how you can quickly download and install WAMP server. The WAMP Server
Installing Java (JDK 7) on Windows 7 Computer Video Tutorial
Installing Java (JDK 7) on Windows 7 Computer Video Tutorial
how to download a file from a folder??
how to download a file from a folder??  i can upload any kind of files to a folder, and only the path of the file is saved into the database, now how a client can download the file from my folder. pls provide me the jsp code
download
download  how to download the file in server using php code: "<form method="post" action=""> enter the folder name<input type="text" name="t1" > <input type="submit" value="search" name="s1"> </form> <
UPLOAD
UPLOAD  how to upload image using html
Struts File Upload and Save
program to upload on the Server and display a link to the user to download... Struts File Upload and Save  ... regarding  "Struts file upload example". It does not contain any