• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in uploading a file using Java program to server- server response gives [Content-Length] => 0  RSS feed

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to upload a file to a server. I have write the client code in java. Server code is written in php.
I am getting Content-Length=0 in server response. But when I upload a file using chrome rest client it gives the content length. Here is my java client code:



Here is server response:


please suggest to solve the issue.

Thanks.
 
Saloon Keeper
Posts: 3336
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see where you are setting the Content-length prior to uploading.
 
Babu Singh
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made some changes now it show the content length but file are not reaching to server.
here is the code:


server response:


But when I upload a file using chrome rest client, file are uploaded sucessfully.
server response:


please suggest to solve the issue.
 
Carey Brown
Saloon Keeper
Posts: 3336
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Babu Singh wrote:I have made some changes now it show the content length but file are not reaching to server.

I still don't see Content-Length appearing around line 34.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!