Welcome Guest, Not a member yet? Register   Sign In
Problem with download helper and AJAX calls. Expertise needed.
#1

[eluser]luismartin[/eluser]
I'm stuck with this issue. I'm not sure if this is something about CI or it is simply a general PHP error. I think it is more of PHP but perhaps someone could help:

I'm trying to implement an images downloader with which the users can download a series of selected images which are previously zipped in a cached file.

The downloader uses a fixed box which is persistent through pages until cancelled or download the images.

The process is like follows:

Quote:1- Once the user has chosen the images to download, he/she clicks on the download button in the download box.
2- Javascript (jQuery more specifically) manages the AJAX request. It sends the list of images to download through POST.
3- PHP gets the request.
4- A hash name is generated with the files list so that any request of the same files will have the same name (this will be useful to cache the requested files).
5- PHP checks whether the cached file already exists.
6a - If it exists, it directly calls the download helper function force_download()
6b - If not, the zip class does its job, archiving the images, and it finally calls $this->zip->download() which in turn gets the zipped file and calls force_download()
7- Javascript gets the response.

All the process seems to work, except that there's no prompt to download any file. The cached zip file is in fact generated and it stores the requested images correctly. The path for the force_download is exactly the same as the one used for the creation of the zip, so I'm not fetching from a wrong path.

The response headers are like follows:

Code:
Connection:Keep-Alive
Content-Disposition:attachment; filename="cache/5cc47c128fc1b6dfa4e433f9e64ca719.zip"
Content-Length:2795303
Content-Transfer-Encoding:binary
Content-Type:"application/x-zip"
Date:Thu, 17 May 2012 15:05:45 GMT
Expires:0
Keep-Alive:timeout=5, max=98
Pragma:no-cache
Server:Apache.......
....

Despite getting Content-Disposition:attachment, I get no file. Is it because of the asynchronous call? What could I do to fix this without giving up using ajax? I want ajax because I'd like to track the request in the same download box.


Messages In This Thread
Problem with download helper and AJAX calls. Expertise needed. - by El Forum - 05-17-2012, 08:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB