I noticed that Kindle recognizes the file types by their extension. So, I wrote a small script on my website that downloads a file, adds ".azw" extension and provide a download link. It works well sometimes but...
The problem is that I'm not a PHP developer and I'm sure the script is not written in the best way. A problem is that the script doesn't download some files (exe) but loads another exe. It gives an error saying that it cannot find the file and creates a filename.exe.azw
file with 0 length. This issue appears only on the Kindle, but on the PC it's ok.
Also it seems that it can download only files smaller than 9 Mb.
The code is here:
<?php
if(!isset($_POST['link'])) {
?>
<form method="post" action="file.php">
<p>
Enter link: http://
<input type="text" name="link" size="20"/>
<input type="submit" name="submit" value="submit" />
</p>
</form>
<?php
} else {
$remote = 'http://' . $_POST['link'];
$download = download($remote);
echo 'Download: <a href="' . $download . '">' . $download . '</a>';
}
function download($url) {
$lastDashPos = strrpos($url, '/');
$local = substr($url, $lastDashPos + 1, strlen($url) - $lastDashPos) . '.azw';
$handle = file_get_contents($url);
file_put_contents($local, $handle);
return $local;
}
?>
The script is at http://forexsb.com/test/file.php if you want to test it.