giganggu
Posts: 2
|
Posted: 05/13/2009, 12:04 PM |
|
Hello sir, I want to get the name of uploaded file from client to server in another file.jsp. How to do it? because I have used session and cookies variable but it cann't work ( the name file cann't knowed) in another file. In this case I am use applet to record sound and send to server. The sound have name randomly. Is it cause the problem to get the name file? There is some jsp synatx :
There is applet I used in my html page, the applet from javasonics,
<applet CODE="com.softsynth.javasonics.recplay.RecorderUploadApplet" mayscript="true" CODEBASE="codebase" ARCHIVE="JavaSonicsListenUp.jar" NAME="JavaSonicRecorderUploader" WIDTH="400" HEIGHT="130">
<param name="uploadFileName" value="voiceprint.wav">
<!-- Server script to receive the multi-part form data. -->
<param name="uploadURL" value="handle_upload_simple.jsp">
<param name="format" value="u8">
</applet>
And there is is piece of my handle_upload_simple.jsp syntax that make filename randomly:
if (fileName.equals("voiceprint.wav")){
Random rnd = new Random();
fileName = fileName.substring(0, fileName.indexOf("."))+"_"+System.currentTimeMillis()+rnd.nextDouble()+".wav";
int lastSlash = fileName.lastIndexOf( '\\' );
if( lastSlash >= 0 ) fileName = fileName.substring( lastSlash + 1 );
lastSlash = fileName.lastIndexOf( '/' );
if( lastSlash >= 0 ) fileName = fileName.substring( lastSlash + 1 );
String pathName = UPLOAD_DIR + "/" + fileName;
File uploadedFile = new File( pathName );
item.write(uploadedFile);
buf.append("FILE:\n field: " + fieldName + "\n file name: " + fileName +
"\n content type: " + contentType + "\n size: " + sizeInBytes );
buf.append("\nSUCCESS - uploaded\n");
String file=(String) fileName;
session.setAttribute("namaFile",file);
}
How to fixed it? Thank you very much for helps
|
|
|
|