• Post Reply Bookmark Topic Watch Topic
  • New Topic

Finding if files exist.. file on local machine, problems on server  RSS feed

 
Mike Ev
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been using Tomcat/local machine to produce some jsp pages for uploading files.

Files are selected and added to a listbox on a form, once the form is submitted - the filenames in the list are uploaded. Firstly there is a check to see if they exist. Something to the effect of..
for each file.

So typically in the listbox there will be C:\readme.txt or something to that effect. On local machine, this works perfectly - files are found and uploaded. However now, since I put this online to a server (which is an oracle server) when the form is submit -- the file can not be found. Initially when submit, the \'s would be removed.. (filenames which are not found are displayed in an error message) e.g C:\log.txt becomes C:log.txt so I added code to change this to unix separators.. C:\log.txt then becomes C:/log.txt ... still it cant find the file.

My experience with unix is fairly limited, is there a certain of writing a filename like that so that the jsp can pick it up? Or perhaps something I should look into to do with server itself? Any suggestions are appreciated. Thanks
 
Pallavi Srivastava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I dont know about oracle server but in tomcat when you make a file, its by default created in bin directory.So you need to give relative path from bin directory.Same way when you use file exists, you have to give relative path from bin directory.
To see where by default file is created just create file without giving any path.Then set all your path relative to the default path.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you really mean "upload" from the browser client machine to the server, you're outta luck on this approach. The files are on the client and the code is on the server.

You can put

on an HTML page so the form submit will upload the file to the web server. Is that what you need?
 
Mike Ev
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heya thanks a lot for the replies. I think this could be on the right lines, thanks.

How my page works is.. I'm uploading the file by getting its inputstream and passing that to a method elsewhere (which uploads the file to a database as a BLOB object). The form i'm using currently uses a 'get' rather than 'post' and the action is run on the same page, but I guess I'll have to change that. I've recently read I'll need to upload the file to the server first but instead of then writing it, I'll pass to the inputstream BLOB method.

So I'm guessing I'll have to 'post' each file individually from a file-input object, then I can get it as a File type using this? I'm fairly new to programming of this type so if anyone has any more sites or suggestions on how to do this, that'd be great! Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!