I'm completely new to php but managed to find a script that will produce the HTTP/1.0 401 Unauthorized message box
This is the message box:
I've heard and seen that you can make this message box be sent through an image. How do i go about doing that?
When done, the steps should be:
I post image.jpg
The authentication message shows up
I know it involves me having a website (example.com). Then on the website i have a folder (example.com/folder) and in that folder i have the image (example.com/folder/image.jpg). What php script do i put in the folder that will result in the image generating the authentication message?
As said before in comments, it has nothing to do with PHP.
The button in your example just set the image URL. But that URL is protected by HTTP Basic Authentication.
To do this just create 2 files in the image folder : .htaccess and .htpasswd
And add HTML and Javascript code like the one on the website :
<img src="" id="downloadImg" alt=""/>
<input type="button" value="Display Image" id="displayImage" onclick="document.getElementById('downloadImg').src='/protected-folder/image.jpg';"/>
Related
Community,
I would like to run a script when you click a link, but this shouldn't open in a new frame, that's why I added the following:
<iframe style="display:none;" name="target"></iframe>
<a href="script.php" target="target">
The script now executes without popping a blank page, joy. But I want the same link to open a PDF file.
<a href="pdf/cesar.pdf" target="_blank" > click here to download </a>
But now the PDF doesn't show, as the target frame is hidden. I can't seem to combine these two. Can someone help me out on this?
Cheers!
Cesar.
It sounds like you might be over-engineering this. Consider the high-level requirements:
The link needs to:
Execute PHP code
Open a PDF file
This sounds like two actions, but from the perspective of the client it's really only one action... open the PDF file. The rest is up to server-side code.
So create one link to perform that one action:
click here to download
As long as getPDF.php returns a PDF file, the client will never know the difference. What that PHP code does before returning that file is up to you. You can have all the code you want in that file, as long as the resulting response is returning the PDF file back to the client.
With the display none it will never show up, you probably should use jQuery, I'd added an ID to the "a"
<iframe style="display:none;" name="target"></iframe>
<a href="script.php" id="openPdf" target="target">
and when click:
$(document).on("click","#openPDF",function(){
$("iframe").css("display","block");
});
I have pdf link file coming from cloud server and i put it into iframe to show it but when i open the page, it direct to download this pdf file and didn't show the file itself, also i used embed and object and it doesn't appear anything.
<iframe src='{$finalurl}' width='1000' height='1000' align='center'></iframe>
Are you required to use an i-frame?
And do you just want to show it, or download it to your 'own' server and show it? That's a big difference.
If you just want to show it (and keep it where it is):
<embed src="http://cloudservice/yourpdf.pdf" width="1000" height="1000" type='application/pdf'>
Good luck
Hi I'm new in PHP and for now, I'm working on a website for myself (using: HTML, CSS, bootstrap, PHP)
but when I'm testing the website in the tools.pingdom.com
this is the image of the warning says:
"Serve the following static resources from a domain that doesn't set cookies"
and because of this gave me a bad grade, you can see the code in the button, it's a very simple code
<img src="source/<?php echo img; ?>" alt="1.jpg" class="img-thumbnail">
what should I do to solve this problem, and how should I serve dynamic data
THANK YOU
obeidarash.ir
Could you please try that code :
<img src="source/<?php echo $img; ?>" alt="1.jpg" class="img-thumbnail">
And one more important thinks that message is suggesting that if your website is www.test.com, then you should load static content from www.companycdn.com. And that new site (www.testcdn.com) is a simple static website that does not serve cookies.
To do this, you need to upload your static resource (e.g. images) to the second domain.
And then update the paths of images to the new domain. For example, instead of this: <img src="logo.jpg"/>, you should change it to this <img src="http://www.companycdn.com/logo.jpg"/>
I am successfully pulling in the url for each image for a particular tag via PHP, but the image simply will not display. I saved the image(s) off locally and it displayed just fine, but not when referencing the url in the src attribute.
<img src="http://origincache-prn.fbcdn.net/1597216_736275239737299_176271816_a.jpg" />
You can follow the above source link to the image, and this is how the img tag is set in html, but it will not display in the browser.
Any suggestions?
Thanks in advance.
I'm not sure but can this have something to do with REFERER-check?
I mean - my chrome doesn't shows up WHY the request get's blocked, when I embed it to a website.
You should figure it out (my linux-curl shows the pic with referer set, but i'm not sure if this works!).
An idea would be to provide a php-file which is just a WRAPPER for sending to image:
<?php // redirect.php
header('Location: ' . $_GET('r'));
die();
usage:
<img src="redirect.php?r=<?php echo urlencode('http://origincache-prn.fbcdn.net/1597216_736275239737299_176271816_a.jpg"');" />
Because modern browsern do not send "REFERER" when redirected through status-header 302 Redirect
just have a try...
This is possibly related--Facebook share dialogs that attempt to share images from the FB CDN origincache end up with a 500 Internal Server Error and a blank page. I know that FB throws an error when sharing other images on FB, but you usually get a descriptive error message and not just a server error.
For some reason, on my server, images do not display if they're remotely (or locally) embedded in an HTML page, but they do work when visited directly.
Embed code:
<img src="http://c.beastsmc.com/banners/creative.png"/>
Here's a fiddle showing the image not displaying: http://jsfiddle.net/gKHM7/
Here's the direct image, which works: http://c.beastsmc.com/banners/creative.png
The .htaccess file is empty.
Any ideas?
As jcansyi mentioned above (upvote him!), the problem was that AdBlocker blocked the image. The reason it was blocking it was the name of the folder (banners). AdBlockPlus blocks any URL with /banners/ in it.