Embed ppt file in webpage - php

I currently have a problem to open a .ppt/.pptx file inside a webpage. I currently have all "uploaded" file in a folder and am able to open .html/.txt files in that folder, but not .ppt/.pptx. Whenever I try, a new window pops up and Windows Uploader starts to run.
<?php
$target_dir = "C:\Apache\htdocs\upload\\";
$target_file = $_FILES['file']['name'];
?>
<iframe src = "upload/"<?php echo $target_file; ?>" name = "iframe_s" id = "download" style = "display:none"></iframe>
Click here to view files
In the above code, I try to list all files in the folder, and the goal is a user can click on one of the file, then the file will open inside the webpage. The main problem I have right now is to have the program each individually attach different .ppt url to different files.
Thank you in advance!

For your question "How to upload to Google Docs".
My first Answer:Why don't you search properly???
If you still don't find it. Then, (taken from here)
You'd use the Google Documents API to upload them using a simple HTTP POST with the data. Here's an explanation how to upload and convert documents: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#UploadingDocs
The link will provide you will examples and all you need to do what you were asking for.
To be more precise this is what you are looking for if you want to upload pdf's: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ResumableUploadPUT
Python Google Documents API guide
PHP Google Documents API guide

Related

Downloading an image from php page

So i have this one small thing im doing, and the thing is: It generates QRcodes using the google qrcode api. Id like to download the generated qr code with the press of a button into a /img folder i have inside the folder my php file is located at, and id need it to save with a numerical number which is the button's id. (it has like 120 buttons and each one has a 0-120 id, id like to save the qrcode that belongs to the button 10 with a name like 10.png) any ideas on how to do so?
__
Little edit: as Man Manam pointed out my question is: I have the image link, i want to save it in my server. Sorry for the confusion.
As you're using Google for creating the QR code, I assume you have a code like this somewhere:
$ga = new \Google\Authenticator\GoogleAuthenticator();
$qr_link = $ga->getUrl($username, $_SERVER['HTTP_HOST'], $secret);
// then you'd display that code with <img src="$qr_link">
What you need to do is to simply download that QR code instead of showing in browser. You can use curl for this or, even simpler, just fopen/file_get_contents if allow_url_fopen is set to ON in php.ini
$image_bin = file_get_contents($qr_link);
file_put_contents($target_file_on_filesyste, $image_bin);

Download Hidden Google Drive data with php

I'm trying to download hidden whatsapp data from Google Drive.
Thanks to Tomers useful instructions here (Thanks!) I can see the data but I'm quite flummoxed how to download it. My main problem is I can't identify a direct link and I can't get my head around the coding to request one.
Many Thanks!
Each file inside the hidden Google Drive directory has an ID, which you can see via $file->getId(). (In my example you have linked, the ID is shown in parentheses next to each file name)
Then, downloading the file should be as simple as
$fileId = '1kTFG5TmgIGTPJuVynWfhkXxLPgz32QnPJCe5jxL8dTn0';
$content = $service->files->get($fileId, array('alt' => 'media' ));
file_put_contents("result_file.crypt9",$content);
Also take a look at the documentation.

Generating text files

My apologies but this is a How to Question. I have limited knowledge of PHP and need figure out if PHP can do this
I have a list of video files that I need tagged with xspf files. And there are thousands of them all in the same directory!
How to make a PHP script read the video file names and create a text file with the video file name inside the text file with other pre-created text and then save the text file the same name as the video file(not the extension)
I searched and could only find a mp3 xspf generator but it creates one playlist of all the mp3 files it found in one directory.. I need to create a xspf file for each video(MP4) file in a directory - http://sourceforge.net/projects/php-xspf-gen/
Or if anyone knows of an windows App that can do the same...
Thank you..
I don't have any experience with xspf files, but creating a file for each video file is pretty easy.
$videoDir = 'C:/path/to/video';
$textDir = 'C:/path/to/textfiles';
foreach(scandir($videoDir) as $filename){
file_put_contents($textDir.'/'.$filename.'.txt', 'Text to put in file');
}
Some additional Code will be needed, but I hope this helps you in some way.

How do I directly upload a file stream to Flickr using a CURL POST?

I'm writing a web app that at one point allows a user to upload a photo to a flickr account (mine). I want to do this without saving the intermediate image on the server my web app is on.
What I've got so far is a page which implements phpFlickr and accepts a POST from a simple html form. I use $_FILES['file']['tmp_name'] as the path for phpFlickr to use. Here's the code:
<?php
require_once("phpFlickr.php");
$f = new phpFlickr("apikey", "secret", true);
$_SESSION['phpFlickr_auth_redirect'] = "post_upload.php";
$myPerms = $f->auth("write");
$token = $f->auth_checkToken();
$phid = $f->sync_upload($_FILES['file']['tmp_name']);
echo "Uploading Photo..." . $phid;
?>
I'm guessing that the tmp file is being lost because of the redirect that happens when $f->auth("write") is called, but I don't know. Is there a way to preserve it? Is there any way to do this without saving the file to the server?
Answer: There is No way to directly upload a file to Flickr without saving it as an intermediate file.
I've moved on to using move_uploaded_file() followed by a flickr API call, and its working perfectly.
I've also managed to get it to play nice with the excellent Jquery Uploadify, which lets me send multiple files to it in one go.

Downloading images from a server iPhone SDK

I have created a program which allows me to upload images to my server. They are given a random file name when uploaded. I want to be able to download all the images from a folder on the server so I can display them in my application. The only example I have seen requires that I know the file name of the images which I don't. How could I download all the images in a given directory (and store the downloads in an NSArray)? If there is no native way to do it does anyone know a way that it could be done via calling a PHP script? (I use a PHP script which the iPhone calls to upload the images).
Thanks.
To list all images in a directory using PHP and return a JSON encoded string:
$path = '/full/path/to/images/';
// find all files with extension jpg, jpeg, png
// note: will not descend into sub directorates
$files = glob("{$path}/{*.jpg,*.jpeg,*.png}", GLOB_BRACE);
// output to json
echo json_encode($files);
you can call a php script that will return the url for all of your images.
something like
yoursite.com/image123.jpg;yoursite.com/image213.jpg;yoursite.com/imageabc.jpg
then you parse the result, split by ";" and get the array of urls which you need to download.

Categories