/*
* Rename the File Uploaded from the form.
*/
Private String getNewFilename (String s ){
Int I = s. indexOf (".");
String s1 = s. substring (I + 1, s. length ());
Java. util. Date today = new java. util. Date ();
String str = "";
// SimpleDateFormat, which is under the java. text package, converts a data object to the string we want
SimpleDateFormat formatter = new SimpleDateFormat ("yyyyMMddHHmmssSSS ");
Str = formatter. format (today );
Return str + "." + s1;
}
/********************* File Upload **************** ************/
FormFile file = ef. getFile ();
String Savefilepath = "";
String Savefilename = "";
If (! (File. getFileName (). equals (""))
{
Try {
InputStream stream = file. getInputStream (); // read the file
Savefilepath = request. getRealPath ("/upload"); // the folder in which the file is stored in the current system path.
Savefilename = getNewFilename (file. getFileName ());
Savefilepath = Savefilepath + "\" + Savefilename;
// Save the file name to the database
Empl. setRemark (Savefilename );
OutputStream bos = new FileOutputStream (Savefilepath); // create an output stream for the uploaded file
Int bytesRead = 0;
Byte [] buffer = new byte [10*1024];
While (bytesRead = stream. read (buffer, 0, 10240 ))! =-1 ){
Bos. write (buffer, 0, bytesRead); // write the file to the server's hard disk.
}
Bos. close ();
Stream. close ();
} Catch (Exception e ){
E. printStackTrace ();
}
}
/********************* File Upload **************** ************/
<Td> </td>
String content = ds. toGBK (ds. toString (String) request. getParameter ("content ")));
<Object classid = clsid: 22d6f312-b0f6-11d0-94ab-0080c74c7e95 width = 450 height = 400> <param name = showstatusbar value = 1> <param name = filename value = '.. /video/upload/<% = sp %> '> <embed src ='/news/upload/1. wmv '> </embed> </object>
Jdbc: oracle: thin: @ 192.168.0.13: 1521: dbstudy
Oracle. jdbc. driver. OracleDriver