2

I've a need that I didn't think to be so weird, but seeking for answer on web I realized it's a bit complicated.

I have a page with a list of documents to download, let's call it index.html. Once a user click on a "download button", a form appears and the user's gonna be requested to provide its email. I have a proxy server file, let's name it proxy.php, which receive an email and a document id, does some things (store the email, read document in a buffer and then provide a http-response with it) and then response with a server status and, eventually, a content.

If I use a html-form to do this, it works perfectly when nothing is wrong, but I can't intercept any exception in case of error Instead, if I use an ajax request, I can manage status codes, but I find my self with my document stored in a javascript variable and I don't know how to use it.

Thanks

Eugene
  • 4,352
  • 8
  • 55
  • 79
balanza
  • 1,059
  • 1
  • 12
  • 34

1 Answers1

1

You can try looking at this thread here: POST to server, receive PDF, deliver to user w/ jQuery

Assuming your document is pdf-based (though other types should be fine), you can try what the accepted answer has provided:

On the server side, add the HTTP header:

Content-Disposition: attachment; filename="whatever.pdf"

Community
  • 1
  • 1
Robert Sim
  • 194
  • 3
  • 13
  • nice, I accepted this answer as it's the most resonable one I found. Anyway, it seems there's no way to do both checking and downloading with a single http call. Thanks – balanza Jun 07 '12 at 11:37