Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 08-01-2014, 03:13 AM   #1
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
page to download an epub to my kobo

Hello,
I have created a php page to download an epub, using headers commands
like this:

PHP Code:
header('Content-type: application/zip');
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($fullPathOfFile); 
and it works nice when I visit the page with my PC. However it doesn't work with the browser of my Kobo Aura, and consequently I can't download my epubs to my e-reader, which was the whole point.
I guess somehow the headers are wrong, could anybody please help me out with this?
Thanks in adavance, French Imp
french imp is offline   Reply With Quote
Old 08-02-2014, 04:29 AM   #2
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
Quote:
Originally Posted by french imp View Post
PHP Code:
header('Content-type: application/zip'); 
Try 'Content-type: application/epub+zip'

The Kobo browser will only download certain file types that it knows how to process.
GeoffR is offline   Reply With Quote
Advert
Old 08-02-2014, 04:47 AM   #3
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
Hello,
Thank you, GeoffR, I tryied it, but it didn't work with epub+zip either.
Any other ideas?
french imp is offline   Reply With Quote
Old 08-02-2014, 06:45 AM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I just did a check with the calibre server. It is setting content type to "application/epub+zip" and works fine. If you are downloading a kepub, make sure the extension is ".kepub.epub".
davidfor is offline   Reply With Quote
Old 08-02-2014, 06:57 AM   #5
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
Thank you very much for your help, davidfor. I tried changing the extension to .kepub.epub, to no avail. Btw when I provide a standard link to the file, it works ok with the extension .epub. Only, that's not what I want to do.
Could there be something wrong with my other header commands?
french imp is offline   Reply With Quote
Advert
Old 08-02-2014, 07:10 AM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by french imp View Post
Thank you very much for your help, davidfor. I tried changing the extension to .kepub.epub, to no avail. Btw when I provide a standard link to the file, it works ok with the extension .epub. Only, that's not what I want to do.
Could there be something wrong with my other header commands?
How are you displaying the download? A link, button or something else? Does anything else happen when you try the download? There was discussion on this recently. From memory, the browser will handle a link OK. But, other things don't work. Especially if something like a popup is displayed.

Also, have you checked the server logs? Does it show the request to get the file?
davidfor is offline   Reply With Quote
Old 08-02-2014, 09:12 AM   #7
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
The download is displayed as a buttun in a formular. The button opens a php page
containing the following code

PHP Code:
$file $_GET['file'];
$dir $_GET['dir'];
$fullPath EPUB_DIR."/$dir/$file";
header("Content-type: application/epub+zip");
header("Content-Disposition: attachment; filename=\"$file\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($fullPath);
exit(); 
where $file is the name of the file, $dir the directory where the file sits.
This works with firefox but not with the kobo's browser. When I click on the button, the screen blinks 2 or 3 times but I don't have the dialog box asking me if I want to download.

Thanks for your time.
french imp is offline   Reply With Quote
Old 08-02-2014, 08:20 PM   #8
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
What does the server show? Does the above code get executed? If you can't see exactly, I suggest adding some logging statements to show. At least enough to see whether the code is being reached.

And what does the code behind the button do? If it is opening another window or tab, I don't think it will work.

I won't have a chance today, but, I can try and have a play at work in the next few days. There's plenty of servers I can try something like this on. It would help to have all the code involved. Any chance? If so, send me PM with a download link, or I can send you an email address to send it to.
davidfor is offline   Reply With Quote
Old 08-03-2014, 01:59 AM   #9
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
Hello davidfor,
thank you very much for your efforts. I have found a way around, thanks to your previous post. Instead of a form button, I have created a link to a dummy epub file, which is really a php file with a .epub extension (I had to change the .htaccess so that apache execute epubs), and this dummy epub executes the above code - and it works. Apparently it has to be a link to xxxx.epub. But since you feel like investigating further I'll do what you ask, I'd prefer not to fiddle with apache in such a silly way. Thanks again.
french imp is offline   Reply With Quote
Old 08-03-2014, 04:09 AM   #10
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
Hi Davidfor,
here's a minimal code exemplifying the problem :
PHP Code:
<?php

// minimal code to illustrate the problem
// this file is epub_test.php
// some epub file test.php should be in the same directory
// the file displays a download button, which works with ff
// but not with the kobo's browser

if (isset($_POST['submit'])) {
    
// code for downloading the epub file
    
$path "";
    
$file "test.epub";
    
header("Content-type: application/epub+zip");
    
header("Content-Disposition: attachment; filename=\"$file\"");
    
header("Expires: 0");
    
header("Cache-Control: no-cache, must-revalidate");
    
header("Pragma: no-cache");
    
readfile($path.$file);
} else {
    
// form with the trigger button
    
echo "<form method = 'post' action = 'epub_test.php'><input type='submit' name='submit' value='Download epub'></form>";

?>
Thanks again!
french imp is offline   Reply With Quote
Old 08-03-2014, 06:21 AM   #11
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,907
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
That will help. But the source for the calling page is also important. Plus if I write it, I'll come up with something different to what you have.
davidfor is offline   Reply With Quote
Old 08-03-2014, 06:32 AM   #12
french imp
Member
french imp began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2012
Device: kobo
This page is the calling page. The script must be called epub_test.php. If you open this script, you'll have the button, and if you click on it, you'll download the file - or not.
french imp is offline   Reply With Quote
Reply

Tags
download, epub, headers, kobo, php


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mini Kobo Mini: can't download epub from Instapaper hefolsom Kobo Reader 11 02-01-2013 02:42 AM
Unable to download epub from kobo store History Kobo Reader 6 04-26-2012 08:49 PM
Kobo epub direct download or sideload epub RareBird Kobo Reader 11 03-30-2012 11:19 AM
Just me? Can't download ADE EPUB from the Kobo site Shankill Kobo Reader 8 03-24-2012 06:31 PM
ePub/Kobo Touch: determine which page ePub opens on? theboyk Conversion 2 12-05-2011 10:19 AM


All times are GMT -4. The time now is 09:20 PM.


MobileRead.com is a privately owned, operated and funded community.