• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

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

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11188
89
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11188
89
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders
https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing
reply
    Bookmark Topic Watch Topic
  • New Topic