My site is designed with JSP pages and Java Servlets.
On my site, I already have the process in place for allowing users to upload files. The files get stored in a folder on my server.
Now I would like to give users the option of uploading a video
and store the video on my server, just as I do with the image files.
Questions
1)
Can I use my code I already have for uploading files? If so, what do I need to add or change?
2)
If I can't use my code, how do I code for the upload of a video?
3)
How do I display the video on an Html or JSP page?
Edit - Update
A snippet of the code for uploading a file - and renaming it newvideo.avi
while(it.hasNext()) {
FileItem item = (FileItem)it.next(); // Create a FileItem object to access the file.
String fieldValue = item.getName();
if(!item.isFormField()) {// formField
File f = new File(fieldValue);
// Prepare streams.
fs = new FileInputStream(f);
fos = new FileOutputStream(complete_path+"\\newvideo.avi");
// Write file contents to response.
byte[] buffer = new byte[(int)f.length()];
int length;
while ((length = fs.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
fs.close();
fos.close();
}//formField
}//while