how can I display an image retrieved using file_get_contents in php?
Do i need to modify the headers and just echo it or something?
Thanks!
how can I display an image retrieved using file_get_contents in php?
Do i need to modify the headers and just echo it or something?
Thanks!
In your url try:
http://user:password@site/
(append whatever the rest of the URL for your API should be)
Fixed it. In case anyone has the same problem:
$url = "http://some-adress/test.php";
$headers = get_headers($url, 1);
$content_length = $headers["Content-Length"];
$content = file_get_contents($url, NULL, NULL, NULL, $content_length);
echo $content;
You need to use the source link of your image.
For example, if laravel expose those static files under http://localhost/public/asset/img
, then you need to write in your JSX:
<img src="http://localhost/public/asset/img/test.jpg" alt="test" />
If you want to display an image file on the phone, you can do this:
private ImageView mImageView;
mImageView = (ImageView) findViewById(R.id.imageViewId);
mImageView.setImageBitmap(BitmapFactory.decodeFile("pathToImageFile"));
If you want to display an image from your drawable resources, do this:
private ImageView mImageView;
mImageView = (ImageView) findViewById(R.id.imageViewId);
mImageView.setImageResource(R.drawable.imageFileId);
You'll find the drawable
folder(s) in the project res
folder. You can put your image files there.
exactly.
Send a
header("content-type: image/your_image_type");
and the data afterwards.