• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

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.
 
Saloon Keeper
Posts: 9348
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • 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
Saloon Keeper
Posts: 9348
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic