Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileInputStream()

Status
Not open for further replies.

jumper2

Programmer
Jul 13, 2007
41
ES
Hi All,

I would need to do a file upload.
The user would choose a file from the local directory like C:/test.xls and makes an upload with.

In my java code I try to get the file content like :

String fileName = "C:/test.xls";
FileInputStream mystream = new FileInputStream(fileName);

but I always get back the same exception that "No such file or directory" even if the file exist on this directory.

Is there somebody who has idea why is that?
 
Remember that filenames in Java are case-sensitive; also, in Windows, I think that you need to use a backslash as a directory separator.
 
I tried also like : C:\test.xls but doesn't works too.
 
If i make a test on my local (just with hardcoded value) like: fileName = "C:\\test.xls"; then the upload works.

But as soon as I try the same hardocded client file path on the server, it says "No such file or directory.
 
Java is not case sensitive, it depends on the underlying OS.

I don't think the server has a c: drive, has it?

Cheers,
Dian
 
Yes, that's right, but otherwise how can I point to the server the directory from where my file is coming?
 
First of all, is the file on the server where you're running the code? If so, just change the path to the actual path of the file in the server. Keep in mind that if you use a relative path, it will start in the applicacion directory.

Btw, what do you mean by "upload"? http upload, ftp upload?

Cheers,
Dian
 
So what I try to do a web application where there is a possibility to choose a file (from local directory or where ever the user that store it) and request a file upload to the application database.
In the db I would put the file content into a blop.
 
Please, can somebody tell me how can I get a file from the user interface (.html) into the database if the field in the db is blop?
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top