求上传音乐到服务器和下载的代码 新手编程,写个音乐网站,知道ftp服务器的地址、上传用户和密码,希望通过上传MP3到ftp服务器获得MP3歌曲链接,并通过链接来播放和下载音乐,但不知道怎么获得链接,一直无从下手,求高手支援,或者传授更好好的播放和下载MP3的方法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 fileUpload 不行吗 你可以先判断下后缀是不是.mp3文件 private File upload;// 封装上传文件private String uploadFileName;// 设置上传文件的文件名private String uploadContentType;// 上传文件的类型public File getUpload() { return upload;}public void setUpload(File upload) { this.upload = upload;}public String getUploadFileName() { return uploadFileName;}public void setUploadFileName(String uploadFileName) { this.uploadFileName = uploadFileName;}public String getUploadContentType() { return uploadContentType;}public void setUploadContentType(String uploadContentType) { this.uploadContentType = uploadContentType;}/** * xml文件上传 * * @return * @throws Exception */ public String xmlUpload() { if (this.getUpload() == null) { this.addActionError("不允许上传空文件,请您重新上传!"); return "Error"; } FileOutputStream fos = null; String basePathfile = 你要上传的文件路径 + getUploadFileName(); try { fos = new FileOutputStream(basePathfile); } catch (FileNotFoundException e) { e.printStackTrace(); } FileInputStream fis = null; try { fis = new FileInputStream(getUpload()); } catch (FileNotFoundException e) { e.printStackTrace(); } byte[] buffer = new byte[1024]; int len = 0; try { while ((len = fis.read(buffer)) > 0) { fos.write(buffer, 0, len); } } catch (IOException e) { e.printStackTrace(); } try { fos.flush(); fos.close(); fis.close(); } catch (IOException e) { e.printStackTrace(); } System.out.println("导入完成"); return SUCCESS; } 问一下大家现在使用的struts的版本?1还是2? 这是什么错误啊HTTP method GET is not supported by this URL Column index 2 is out of range. 关于submit的问题。 我的小程序为什么不能正常的显示 怎么传递参数 jsp的难题,有点难度!高手来看看!正确马上结贴! 关于发送邮件时的中文问题? 请大家帮我看一下下面的servlet,有何问题,为什么总是发不出去呢?急急急!! 就这么多分了,全部奉献,那位大虾有论坛的主贴和跟贴的顺序的算法源代码? 如何打印等腰三角形 怎么给现有的增删改查页面做个实时帮助啊
private File upload;// 封装上传文件
private String uploadFileName;// 设置上传文件的文件名
private String uploadContentType;// 上传文件的类型
public File getUpload() {
return upload;
}public void setUpload(File upload) {
this.upload = upload;
}public String getUploadFileName() {
return uploadFileName;
}public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}public String getUploadContentType() {
return uploadContentType;
}public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
/**
* xml文件上传
*
* @return
* @throws Exception
*/
public String xmlUpload() {
if (this.getUpload() == null) {
this.addActionError("不允许上传空文件,请您重新上传!");
return "Error";
}
FileOutputStream fos = null;
String basePathfile = 你要上传的文件路径 + getUploadFileName();
try {
fos = new FileOutputStream(basePathfile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
FileInputStream fis = null;
try {
fis = new FileInputStream(getUpload());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
byte[] buffer = new byte[1024];
int len = 0;
try {
while ((len = fis.read(buffer)) > 0) {
fos.write(buffer, 0, len);
}
} catch (IOException e) {
e.printStackTrace();
}
try {
fos.flush();
fos.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("导入完成");
return SUCCESS;
}