-1

i have to upload an image in server location using servlet but url formating ia having some problem . i am able to upload image in local machine but when it is deployed on server with some URL like http://domain.com/folder then it is having some problem . it is part of code from where location is read by servlet..

<context-param>
 <description>Location to store uploaded file</description>
 <param-name>file-upload</param-name>
  <param-value>
        F://Servers//Images//
  </param-value>

and it is part of code i am using to upload to server ..

if( fileName.lastIndexOf("\\") >= 0 ){
           file = new File( filePath + fileName.substring( fileName.lastIndexOf("\\"))) ;
        }else{
           file = new File( filePath + fileName.substring(fileName.lastIndexOf("\\")+1)) ;
        }
        fi.write( file ) ;

when is changed to http://domain.com/folder then it is not able to write to that location since http:// is changed to http:/

please help to resolve the issue...

zytham
  • 613
  • 1
  • 12
  • 27

1 Answers1

0

you can read more on how to upload files or images using servlets here

How to upload files to server using JSP/Servlet?

Community
  • 1
  • 1
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125