How to display pdf files from database in Google Docs? - php

Here is my code.
<i class="text-warning">View </i>
It echos the file.pdf in the database, when I clicked the link I want to redirect in Google docs. the google docs said they cannot find the specified folder.
Can someone help me to view the files into Google Docs after i clicked the link?

Try rawurlencode() and do not forget about = here ?url=:
<a href="http://docs.google.com/viewer?url=<?php echo rawurlencode($file_row['floc']); ?>">
But your $file_row['floc'] does not contain an URL:
http://www.domain.com/uploads/4145_File_app-developer-guide-2.4.pdf
a path only:
uploads/4145_File_app-developer-guide-2.4.pdf
Try add a schema and a domain:
<a href="http://docs.google.com/viewer?url=http://domain.com/<?php echo rawurlencode($file_row['floc']); ?

Related

How to open a pdf file in new tab from controller PHP (laravel)

Hi I am new to php programming. I am using laravel 5.2 now.
I have used an external service to create a pdf from my html page. For that I have used pdfcrowd. I wrote the content to a pdf file in my local system. Its location is /var/www/html/testproject/test_pdf.pdf.
It works fine. Now my requirement is that, I have to open that pdf file in a new tab from my controller. My controller name is adminController. Inside that I used a function to open the pdf.
Please see the code below:
public function open_pdf() {
$file_location='/var/www/html/testproject/test_pdf.pdf';
----------?
}
Please suggest your ideas.
The important thing to understand is that, we can't open a new tab from php controller. So In the view page (testpage.blade.php) I used 'target="_blank" code in a tag. please see the code below:
<a href="{{ url('/') }}/testproject/openpdf"> target="_blank"
Try to add target="_blank" in your html tags it will work fine.
You may have use like this
<a href="{{ url('/') }}/testproject/openpdf">
please try with this
<a href="{{ url('/') }}/testproject/openpdf" target="_blank">

Output php URL as a bootstrap button only

First and foremost excuse me, I'm totally new to PHP.
I'm looking to echo a link back to the comic's description/home page currently being read on my site as a clickable bootstrap button with a font awesome icon assigned to it. But, I'm not entirely sure how would I go about doing that.
I'm using a comic reader software; here's the php code that outputs the link to the comic's home page
<?php echo $comic->url() ?>
This is the code I've used to output the link inside a bootstrap button with a font awesome icon:
<button type="button" class="btn btn-danger"><i class="fa fa-level-up"><?php echo $comic->url()?></i></button>
What happens here is that the url is outputted as a clickable text link using the comic's title inside the button. I'm trying to learn how to have the link phrased as a button only.
Live example: of the button
Thanks a lot,
See the Comic model so you know what $comic is set to.
You're using $comic->url() which runs:
public function url()
{
return '' . $this->title() . '';
}
But if you only want the href part, the above function calls this method:
public function href()
{
return site_url('series/' . $this->stub);
}
So your solution is as simple as:
<?= $comic->href() ?>
After looking at your site , i saw that , coming <?php echo $comic->url()?> is doing echo of link with anchor tag as well , then i did visit the comic reader's repository on github , and explored the code files and i found that there are two type of linking system :
$comic->url(); - this echo the link with anchor tag
$comic->href(); - this echo only the link that you need , in your case
and for title echo you can use the below
<?php echo $comic->title();?>
You can create an anchor tag and give that anchor tag the classes that you have given to the button and use $comic->href(); to get only the link that you need.
<a href="<?php echo $comic->href();?>" class="btn btn-danger">
<i class="fa fa-level-up"></i><?php echo $comic->title();?>
</a>
as Rohit kishore suggested , you can also try to use echo strip_tags($comic->url()) if you have to use $comic->url();
<i class="fa fa-level-up"><?php echo $comic->title();?></i>

Facebook share only certain div

So I have the following code for facebook share.
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" class="post_share_facebook" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=220,width=600');return false;">
<i class="icon-facebook"></i>
</a>
Right now, when the share button is clicked, the whole snapshot of the page is shown on the share window.
On a php file where this share button is located, I have a specific div which I want to show on the Facebook share window instead of the whole snapshot of the page.
Does anyone know how I can do this?
Thanks!
Not sure if its possible that way, you can try <?php the_permalink(); ?>#your_div_id
Another alternate would be using open graph

How to share post in Facebook using PHP?

I have 5 divs in my program and in each div, it contains different content and share on FB button. Now when I click on this button, I need to share that particular content on FB. How can I do that?
There are 2 ways. Below links may help you. I am using code from this article.
1) Using javascript:
http://thinkdiff.net/facebook/new-javascript-sdk-oauth-2-0-based-fbconnect-tutorial/
2) Graph API
http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/
Try this
<?php
$title=urlencode('Dressfinity');
$url=urlencode('http://www.facebook.com/pages/Dressfinity-LLC/208406062583392 ');
$image=urlencode('http://livemarketnews.com/dressfinity/skin/frontend/default/default/images/logo.jpg');
?>
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>', 'sharer', 'toolbar=0,status=0,width=548,height=325');" target="_parent" href="javascript: void(0)">
Share our Facebook page!
</a>
For each div.
FB php SDK: https://developers.facebook.com/docs/reference/php/
This is full FB documentation for their PHP API.

How to open audio and video files in lightbox in wordpress

I want to open the audio and video files through the plugin in the wordpress.and i am currently use the plugin wp video lightbox plugin in the wordpress.
I have iframe code like..
<iframe width="325" height="64" src="http://www.ewihosting.com/evp/?id=Mi0wMSBJbnRlcm5ldCBSaWNoZXMgTWFkZSBFYXN5Lm1wMw%3D%3D&profile=default&mode=iframe" frameborder="0" style="background:#fff;" allowfullscreen></iframe>
and i use the logic like..
<li>
<span class="audio_upload_icon"></span><h3>Audio</h3><h4>Lesson #1</h4>
</li>
and i click on the image then open the lightbox but my audio file is not working but may video file is working are correctly.
So please advise me to which plugin very useful for me or any done the code modification.
Thank You.
I am assuming that you are self hosting your Wordpress, or at least you have access to your ftp files in your hosting service. If so, then:
You may wish to save a myvideo.html file in your server, then invoke it via
<li>
<a href="myvideo.html" rel="wp-video-lightbox[iframes]">
<span class="audio_upload_icon"></span>
<h3>Audio</h3>
<h4>Lesson #1</h4>
</a>
</li>
You can include the full path of your local html files, which allow you to make a folder inside of which you can save all your needed iframes, the code will look like this:
<li>
<a href="myvideo.html" rel="wp-video-lightbox[iframes]">
<span class="audio_upload_icon"></span>
<h3>Audio</h3>
<h4>Lesson #1</h4>
</a>
</li>
Lightbox, Shadowbox and other similar tools/plugins will now work. BUT if you are not self-hosting your wordpress nor be able to gain access to the files on your web hosting, you will need a different solution. Please let us know what is the case in order to provide the proper support.
Good luck!
You can use Fancbox Jquery Plugin.
Its pretty simple and usage. For more click here.

Categories