问题
I am trying to upload Image but I can't. When my application is in local disk i.e. d:\ then it works. But when I put my application on out office server and when I am trying to upload image then it isn't working. Before I am using following path :
final String path = "D:\\Workspace\\B2B Solution\\WebContent\\product_images\\";
now my application reside at :
\\ADMIN\keyur\Workspace\B2B Solution\WebContent\product_images
place i.e. on network. So which address I have to pass in servlet I don't know.
Any help please ?
回答1:
Probably you need to create the path like this:
File fp = new File("\\\\ADMIN\\keyur\\Workspace\\B2B Solution\\WebContent\\product_images");
You need to escape all the slashes in the path.
Another option is to use the third party JCIFS API to create a connection through Samba to the network share; that also gives you control over which user is used to connect to the share which might be helpful.
回答2:
start your path with "..\Workspace\B2B Solution\WebContent\product_images" dont use full path
回答3:
In That case you need to check your path. With correct path you will not get any problem.
来源:https://stackoverflow.com/questions/20492020/how-to-upload-image-at-specific-place-or-path