Hi all!
i'm trying to download an image from a server and a string, by using a php file. I want to avoid to use base64 encode and decode. This is my php code
And this is my code to download, but i get Error in bitmap. Some advices?
i'm trying to download an image from a server and a string, by using a php file. I want to avoid to use base64 encode and decode. This is my php code
B4X:
<?php
define ('SITE_ROOT', realpath(dirname(__FILE__)));
$target_dir = SITE_ROOT . "/user_images/";
$target_file = $target_dir . basename($_GET["name"]);
$target_cache = substr_replace($target_file , 'cache', strrpos($target_file , '.') +1);
if (file_exists($target_cache)) {
$myfile = fopen($target_cache, "r") or die("Unable to open file!");
$boh = fgets($myfile);
if ($boh !== $_GET["cache"]) {
//echo $boh;
header("Content-disposition: attachment; filename=\"$target_file\"");
header('Content-transfer-encoding: binary');
header('Content-type: image/jpg');
echo file_get_contents($target_file);
}
} else {
echo "The file $target_cache does not exist";
}
?>
And this is my code to download, but i get Error in bitmap. Some advices?
B4X:
Dim j As HttpJob
j.Initialize("",Me)
j.Download2("www.site.com/try.php",Array As String("name",name,"cache",cache))
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
Dim bmp As Bitmap = j.GetBitmap 'error
...
....
...