Solved

my PHP code generate XML: I want to add some code to get a PowerPoint

Posted on 2013-05-24
2
342 Views
Last Modified: 2013-05-26
Hi,


I did an xml file for power point
The problem is my CEO wants not to download XML file he wants me to convert in normal Power Point.

Here is the code I've found on the Internet Google search  I have try to rename but it is not OK.


Can some one give me the code Please for that



<?php

// Extensions des fichiers autorisés à être téléchargés, à modifier. Sans les points.
$exts_allowed = array ( 'xml','txt' , 'htm' , 'html' , 'phtml' , 'xhtml' , 'dhtml' );


//----------------------------------------------------
// MESSAGES D'ERREUR
//----------------------------------------------------

$msg [ 'no_file_to_dl' ]      =  'Aucun fichier à télécharger.';
$msg [ 'file_doesnt_exist' ]  =  'Le fichier que vous tentez de télécharger n\'existe pas.';
$msg [ 'file_not_allowed' ]   =  'Vous ne pouvez pas télécharger ce fichier.';

//echo "*".$_GET [ 'file' ];




$_GET [ 'file' ]="OUTPUT.xml";
//$_GET [ 'file' ]="PBE_STAT_CRM_MASK_STEP1_REELLES_MASK_P2_V1OKREELLE_V3.xml";
if ( isset ( $_GET [ 'file' ] ) )
{
      $file = trim ( $_GET [ 'file' ] );
     
      if ( @ file_exists ( $file ) )
      {
            $infos = pathinfo ( $file );
           
            if ( in_array ( $infos [ 'extension' ] , $exts_allowed ) )
            {
            @ header ( 'Content-Transfer-Encoding: binary' );
            @ header ( 'Content-Disposition: attachment; filename="' . str_replace ( ' ' , '_' , $file ) . '"');
            @ header ( 'Content-Length: ' . @ filesize ( $file ) );
            @ readfile ( $file );
            }
            else
      {
                  echo $msg [ 'file_not_allowed' ];
            }
      }
      else
      {
            echo $msg [ 'file_doesnt_exist' ];
}
}
else
{
      echo $msg [ 'no_file_to_dl' ];
}

rename ( "OUTPUT.xml" , "OUTPUT.pptx");


?>
0
Comment
Question by:DavidInLove
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39196211
You can have this file open directly in powerpoint by sending the appropriate content-type header. Leave the file as .XML but then add this to your header statements

@header("Content-type: application/vnd.ms-powerpoint");

Look here for additional MS mime types

http://filext.com/faq/office_mime_types.php
0
 

Author Closing Comment

by:DavidInLove
ID: 39198442
@julianH

I have tried that (add what you said at the beginning of my xml file) but it is not OK


@header("Content-type: application/vnd.ms-powerpoint");
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="PowerPoint.Show"?>

Can you please explain further more please?
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question