Pergunta

My form has an upload button for the user to save file images.

ServletContext context = ServletActionContext.getServletContext();

String appPath = context.getRealPath("");
String filePath = appPath+"\\images\\categories";

File fileToCreate = new File(filePath, getMyFileFileName());
FileUtils.copyFile(getMyFile(), fileToCreate);

I need to upload the picture and put it on the image/categories folder for future access. It is working well in my localbuild but when I deployed it on the cloud by uploading the .war file, it doesn't work anymore. It cannot find the image.

HTML Error upon accessiing the image is as follow

type Status report

message /Teapop/images/categories/team.png

description The requested resource (/Teapop/images/categories/team.png) is not available.

What am I doing wrong?

Foi útil?

Solução

please try to use File.separator instead

String filePath = appPath+File.separator+"images"+File.separator+"categories";

and please give me some feedback

Hope that helps .

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top