upload and download video

upload and download video

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 Tutorials/Questions & Answers:
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
Advertisements
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
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
ASP .Net Upload Video on youtube
ASP .Net Upload Video on youtube  Hi, I Naushad Ansari trying to upload video on youtube using my asp .net web application. I have read the documentation of youtube and I have created the application also but I am not getting
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
java/jsp code to download a video
java/jsp code to download a video  how can i download a video using jsp/servlet
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
ModuleNotFoundError: No module named 'odoo8-addon-website-upload-video'
ModuleNotFoundError: No module named 'odoo8-addon-website-upload-video' ...: ModuleNotFoundError: No module named 'odoo8-addon-website-upload-video' How to remove the ModuleNotFoundError: No module named 'odoo8-addon-website-upload-video'
ModuleNotFoundError: No module named 'youtube-video-upload'
ModuleNotFoundError: No module named 'youtube-video-upload'  Hi...: No module named 'youtube-video-upload' How to remove the ModuleNotFoundError: No module named 'youtube-video-upload' error? Thanks   Hi
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 Large files in jsp
Upload and Download Large files in jsp  I am not able to download large files (>200mb) from any server. I need a code to download and upload large files (atleast 4 gb) to a server using jsp page
How to upload and download file in hadoop?
How to upload and download file in hadoop?  Hi, I am trying to learn to upload the file on the Hadoop HDFS and then download the same file for learning the process. How to upload and download file in hadoop? What
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
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
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
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
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
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
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
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
JDBC Video Tutorial: How to download JDBC Driver for MySQL?
First thing to develop the JDBC program is to download the JDBC Driver... the MySQL database, so we have download the JDBC Driver for the MySQL... it in windows as well as on the Linux system. So, just download the Zip package
video
video   I need code for creating video chatting in a webpage.Can you send me the code related to that or API
UPLOAD
UPLOAD  how to upload image using html
Video Tutorial: How to download JDBC from MySQL?
How to download JDBC from MySQL? The video here teaches on how to download... file Here is the video tutorial of "How to download JDBC Driver... download process: Go to mysql.com from the search engine you are using
Download
Download JDK  How to Download the latest Version of JDK?   Download OST to PST converter from: http://www.osttopst.info
Download.
Download.  I need a swing program to download a file from the server
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> <
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
Video Tutorial: Features of eclipse Luna 4.4.2 - learn to download and install
Features of eclipse Luna 4.4.2 - learn to download and install In this video... to download and install it. Luna 4.4. is the latest  version. In this version... tools platform and memory analyzer. We download the eclipse luna 4.4 from here
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
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
video rating
video rating  Please send me the code for video rating using java
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
How to download and install MySQL on Windows 10?
MySQL Installation on Windows 10 This video tutorial teaches you to install... of the GNU General Public License.ADS_TO_REPLACE_1 In this video tutorial we... the video you will see the complete installation process, here I am going to write
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
Download Eclipse with Maven Plugin support
Plugin. In this video tutorial teaches you how to download, install and then create... Here is the video tutorial of "Download eclipse with maven plugin and create...Video tutorial of Downloading the Eclipse IDE having Maven Plugin support
How to download ,install and use jQuery in the web application?
interaction.ADS_TO_REPLACE_1 Here is the video tutorial of "How to download, install and use jQuery?": In this video we will and learn how to download, install...How to download, install and use jQuery in the web application? jQuery
video chat
video chat  Hi , how can implement video chat using jsp and servlet .but not use applet . I want to implement video chatting system in my.... Is there any other way to implement video chatting without applet? How
video playing
video playing  please give me a sample code to play uploaded videos i have alredy uploaded videos but when i try to play it using html5 nothing happens i need youtube like video playing . please somebody help me
image upload in webapp/upload folder
image upload in webapp/upload folder  sir i want to store upload image in my project directory WebApp/Upload_image/ pls send the jsp servlet code when i upload the image one error found "system cannot found the specified path
File Download in jsp
File Download in jsp  file upload code is working can u plz provide me file download

Ads