I want to print this PHP image http://www.putlocker.com/include/captcha.php?_CAPTCHA&t=0.94178300+1332596358 in my PHP script.
Source (is the captcha image): http://www.putlocker.com/authenticate.php?login
What can I do?
It doesn't seem to let you access that image other than by viewing it on the webpage. The captach image contains a time parameter (&t=sometime). It also throws a 500 server error so unless you're willing to work this out then I'd probably just leave it alone.
Related
I have an external resource for my images let's say https://api.domain.com/api/downloads/{file_id}. The file gets downloaded after I visit that page. In this case I want to know the mimetype of the file. file_get_contents() doesn't work because the file is downloaded after I visit the page.
This means that I get HTML as output when I dump the result of file_get_contents(). I don't have any hold on how images are served to my application. So I guess I have to find a solution for this problem.
Is there a way to get the mimetype of a file after the page is loaded and it downloaded the file? If something I just wrote is not clear enough please let me know then I try to explain it further. Thanks in advance.
Some more detailed information:
I am currently creating an EML export from data from an external API from Genesys. This is pure PHP and thus I can’t make use of any client-side code like Javascript. The inline images in the body don’t show on in the EML export email body. I think this is because Genesys saves those images somewhere on their side. The image is not directly available from the URL they gave to me, because when I visit that page the page downloads a file but it is not directly served on that page.
To show the images inside the email body I want to encode them to base64 and change the src of the image to the base64 encoded image. To do so I need to know the filetype which I can’t get as described above.
Did you try with the onload property on the <img /> tag ?
<img src="w3html.gif" onload="loadImage()" width="100" height="132">
<script>
function loadImage() {
alert("Image is loaded");
}
</script>
https://www.w3schools.com/tags/ev_onload.asp
You will need to use javascript as the image is on a remote server and loaded on client side
Recently I have moved from my staging server to production server and I don't have access to any of these servers.
Both of these servers are linux.
On the new server while generating the pdf using mPDF with symfony 1.4 framework, images like rupee symbol are not getting displayed instead a small red "x" symbol is getting displayed in pdf.
Also, when I try to give background image to pdf, full image path like "http://example.com/image/rupee-image.jpg" is getting displayed instead of image.
Rupee symbol, other images and background images are working fine on my staging server.
When, I did $mpdf->showImageError(), It's saying "mPDF Image Error: Could not find image file" and pasting the url in browser displays the image perfectly.
Any help will be greatly appreciated.
mPDF is telling you that it's not finding the image.
Without seeing your code it's difficult to hint you on what's wrong.
Still you probably what to try referring to your images using a full path locally.
So instead of reference like http://example.com/image/rupee-image.jpg
use something like /var/www/mysite/image/rupee-image.jpg , same as if checking the image is there using the command line.
HTH
I had similar problem, i fixed it with replacing http:// to https://. Watch out for it.
I fixed it myself... I have created a variable in my template and then replaced that variable with image location from my action class, using $mpdf->WriteHTML(str_replace('rupee_symbol','₹',$html1));
My problem was PHP 7 in this case! I check condition
if (!empty('/images/someimg.png')) {
echo '<img ...';
} else {
echo 'error in PHP 7';
}
Be carefull using it. Version PHP 7.0.19
I need to get a image saved on a mysql DB to a folder into the server...
I have the script: watch_pic.php the which get the byte of the image and prints it into a based64 code, I send the Header and the image can be seen on browser, then if I write on the browser 'watch_pic.php?id=1234' it will display and image. I need to copy these image to a folder in the server with any name... I think that using the 'copy' function I could get the image, but it don't works. I can do it using CURL, but I don't wanna like to use this, cause i haven't install it on the server, and could be conflictive with other extras... How can I caopy the image without using CURL??
If you included the code of watch_pic I could give you the exact code to make it work (and if you put it up I can certainly improve this answer). However I can give you a suggestion:
somewhere in that file there will most likely be a line like this:
imagejpeg($img);
(or imagepng or imagegif)
and just change that to something like this:
if (isset($_GET["save"]) {
imagejpeg($img,$_GET["save"]);
}
else {
imagejpeg($img);
}
and call it by image_pic.php?id=####&save=filepathandnametosaveto.jpg
HTH;
Nick
I'm working with WampServer Version 2.0 on Windows XP and FireFox 3.6.8.
I'm trying to get image content via PHP script like this:
HTML:
<img src='temp_get_file.php' alt='picture not found' />
PHP: (temp_get_file.php)
<?php
header('Content-Type: image/png');
$img = imagecreatefromjpeg("1.png");
imagejpeg($img);
imagedestroy($img);
?>
The HTML, PHP, and 1.png files are located in the www directory of WampServer.
Unfortunately, I got this error (in HTTPFOX plugin in FireFox):
Error loading content (NS_ERROR_DOCUMENT_NOT_CACHED)
and I see "picture not found".
If I put the image in HTML directly like this:
<img src='1.png' alt='picture not found' />
everything works fine.
What's wrong with my PHP ?
This may just be a problem in your example, but this won't work:
imagecreatefromjpeg("1.png")
^ ^
JPEG != PNG
Not with your PHP actually but with your PHP skills :)
Some advises to improve
you have to debug your application instead of asking community.
To do so, you have to
a) request your image file directly, by typing temp_get_file.php into browsers address bar, to let you see output of the script
b) put Content-Type header output as low in the code, as possible, to let PHP sent text/html in case of some errors
c) have displaying errors on
or
instead of all this above you can turn logging errors on and catch the error in the error log.
both methods will let you to get PHP error message - a thing you really need here, instead of useless firefox complains.
and this error message is pretty clear - wrong file format.
if it's the only thing what your script does, you don't need all these GD functions. thats useless. if you need to output some file to the browser, just do it. readfile("1.png") is enough
Last week I converted my page img src values from pointing at image files to using a PHP script to serve up the images. The primary reason was to accommodate both files and database BLOBs as the actual source.
Now when a user goes to a page, sometimes images show and sometimes not. If not, and the page is refreshed\reloaded, then the image appears. When images do not appear, sometimes it is an image the user has already accessed previously today.
I am stumped.
Here is the img tag:
<img src="../somedir/image_script.php?i=1234">
The image_script.php file figures out where to get the image from, then finishes up with:
header("Content-type: image/jpeg");
if($from_db){
print $image_blob;
} else {
$im = imagecreatefromjpeg($image_file);
imagejpeg($im,null,100);
imagedestroy($im)
}
I am using PHP 5.2.8 on IIS 6 using FastCGI. There are no cache headers on the image_script.php file nor on the directory it is in. Currently 99.9% of the images are file based, so I do not know if there is a difference in result between db-based and file-based images. When I go directly to image_script.php in my browser it returns the requested image (i=????) 100% of the time.
a> Any clue as to why the hit and miss with images being displayed? and,
b> what would be a proper way to actually cache the images served up by the PHP script? (they are very static)
Scott
Hmm. Can't tell for sure, but maybe your imagecreatefromjpeg is occasionally running out of memory? In that case, you'd serve an error message out as JPEG data and never see it, right?
Incidentally, wouldn't just grabbing the image file in as a string and shovelling it out without going through imagecreatefromjpeg/imagejpeg/imagedestroy be more efficient? It looks like you're reading a JPEG file, creating an internal PHP memory image from it, then reconverting it to a JPEG (at hefty 100% quality) then serving that data out, when you could simply read the JPEG file data in and print it, like you do from the database.
What happens if you do, say...
...
} else {
header ('Content-length: ' .filesize($image_file));
readfile ($image_file);
}