Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-05-24
2
Medium Priority
?
345 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 59

Accepted Solution

by:
Julian Hansen earned 1500 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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