我是linux环境的新手。我有一个在Windows环境中运行良好的Web应用程序,它是使用play framework开发的。现在我们要将我们的应用程序从windows移动到linux。这里的问题是,在上传文件时我收到了内部服务器错误。我已经为文件夹提供了777的权限。即使控制器没有调用该方法,如何解决?我无法找到错误,提前感谢所有帮助。
@helper.form(action =routes.HoForms.uploadHoFormsByHeadOffice(),'enctype -> "multipart/form-data" ,'id -> "shiftSummaryForm")
{
}
在路线档案中:
POST /HeadOfficeForms/upload controllers.HoForms.uploadHoFormsByHeadOffice()
控制器方法:
public static Result uploadHoFormsByHeadOffice() throws Exception {
Logger.info("@C HoForms -->> uploadHoFormsByHeadOffice() -->> ");
}
上传方法():
public static Result uploadHoFormsByHeadOffice() throws Exception {
final String basePath = "/var/www/html/pdfs/";
Date date = new Date();
DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
String startDate = format.format(date);
date = format.parse(startDate);
play.mvc.Http.MultipartFormData body = request().body()
.asMultipartFormData();
String formType = body.asFormUrlEncoded().get("formType")[0];
FilePart upFile = body.getFile("hoFormFiles");
String fileName = upFile.getFilename();
try {
File ftemp = new File(basePath + "HeadOfficeForms/" + formType
+ "");
ftemp.mkdirs();
String filePathString = "HeadOfficeForms/" + formType + "/"
+ fileName;
File f1 = new File(ftemp.getAbsolutePath() + "/" + fileName);
File file = upFile.getFile();
file.setWritable(true);
file.setReadable(true);
f1.setWritable(true);
f1.setReadable(true);
Files.copy(file.toPath(), f1.toPath(), REPLACE_EXISTING);
HoForm.create(fileName, date, formType, filePathString);
flash("success", fileName + " Has been Successfully Uploaded");
} catch (IOException e) {
e.printStackTrace();
}
return redirect(routes.HoForms.showHoFormUploadPage());
}