<tr> |
<td align= "right" >业务图片:</td> |
<td><input type= "file" name= "file" id= "imgurl" style= "border:1px solid #7F9DB9;" /><span class = "checkts" > *</span><span class = "sm" > 说明:游戏图片</span><br/></td> |
</tr> |
<font color= "#e78608" >------解决思路----------------------</font> |
你可以在system.properties中定义你的路径名 |
TempFilePath = C:\\ 1 \\ |
RealFilePath = C:\\ 2 \\ |
String filepath = PropertyUtil.getProperty( "TempFilePath" ); |
String drcPath = filepath+compid+File.separatorChar; |
File drcpath = new File(drcPath); |
File file = new File(drcPath+ this .getUploadFileName()); |
if (!drcpath.exists()){ |
drcpath.mkdirs(); |
} |
if (!file.exists()){ |
02Service.copy( this .upload, file); |
// file.delete(); |
} |
|
return SUCCESS; |
public void copy(File src, File dst){ |
|
try { |
InputStream in = null ; |
OutputStream out = null ; |
try { |
in = new BufferedInputStream( new FileInputStream(src), Ass02Constant.BUFFER_SIZE); |
out = new BufferedOutputStream( new FileOutputStream(dst), Ass02Constant.BUFFER_SIZE); |
byte [] buffer = new byte [Ass02Constant.BUFFER_SIZE]; |
while (in.read(buffer) > 0 ) { |
out.write(buffer); |
} |
} finally { |
if ( null != in) { |
in.close(); |
} |
if ( null != out) { |
out.close(); |
} |
} |
|
|
} catch (Exception e) { |
e.printStackTrace(); |
} |
|
} |
//源代码片段来自云代码http://yuncode.net |
|