Connecting Tech Pros Worldwide Forums | Help | Site Map

ppt file upload and download

Newbie
 
Join Date: Jun 2008
Posts: 6
#1: Jun 30 '08
How i can upload a ppt file and store it to some database and later download it.
I have a code for uploading a txt file but id doesn't work. Plz help me in this regard.
here is the code...
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. function upload_form(){
  3. ?>
  4.       <table border = "1" align="center">
  5.       <tr><td>
  6.       <form   method="post" enctype="multipart/form-data" action="<? echo $_SERVER['PHP_SELF']?>">
  7.       <input type ="file" name="userfile">
  8.       <input type="submit" name="action" value="upload">
  9. </form>
  10. <td></tr>
  11. </table>
  12. <? 
  13. }
  14. function upload_file(){
  15.       $uploaddir="D:\personal\source code";
  16.       //echo "$uploaddir";
  17.       $userfile_name=$_FILES['userfile']['name'];
  18.       //echo "$userfile_name";
  19.       $userfile_tmp_name=$_FILES['userfile']['tmp_name'];
  20.       $userfile_size=$_FILES['userfile']['size'];
  21.       $userfile_type=$_FILES['userfile']['type'];
  22.  
  23.       if(isset($_ENV['WINDIR'])){
  24.            // $userfile=str_replace("\\\\","\\",$_FILES['username']['name']);
  25.       }
  26.       $filename=basename($userfile_name);
  27.       if($userfile_size<=0) die("$filename is empty.");
  28.       if(!$move_uploaded_file($superfile_tmp_name,"$uploaddir/$filename"))
  29.             die("Cannot copy $userfile_name to $filename");
  30.       if(isset($_ENV['WINDIR']) && ! unlink($userfile))
  31.             die ("Cannot delete the file $userfile_name.");
  32.       echo "$filename has successfully uploaded.<BR>";
  33.       echo "filesize: ".number_format($userfile_size)."<BR>";
  34.       echo "filetype: $userfile_type<BR>"; 
  35.  
  36. }
  37. ?>
  38.  
  39.  
  40. <html>
  41. <head>
  42. <title>Uploading a file to remote server</title>
  43. </head>
  44. <body>
  45. <?php
  46. if($_POST[action]=='upload'){
  47.       upload_file();
  48. }else {
  49.       upload_form();
  50.   }
  51. ?>
  52. </body>
  53. </html>

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#2: Jul 1 '08

re: ppt file upload and download


Hey there.
Check out this tutorial.
Newbie
 
Join Date: Jun 2008
Posts: 6
#3: Jul 2 '08

re: ppt file upload and download


thanks mark. I will try
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#4: Jul 2 '08

re: ppt file upload and download


Quote:

Originally Posted by rubelpasha

thanks mark. I will try

Post back if you need help.
Newbie
 
Join Date: Jun 2008
Posts: 6
#5: Jul 7 '08

re: ppt file upload and download


hi all,
I want to upload a ppt file to a database and download it by using php. can anyone help me?? plz, i m in trouble.

i can do this with atxt file. but in case of ppt id doesn,t work
Newbie
 
Join Date: Jun 2008
Posts: 6
#6: Jul 7 '08

re: ppt file upload and download


Hello mark,
I read this tutorial. But there is nothing for ppt file uploading and downloading. I think i cant extract the header of ppt file.
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#7: Jul 7 '08

re: ppt file upload and download


Quote:

Originally Posted by rubelpasha

Hello mark,
I read this tutorial. But there is nothing for ppt file uploading and downloading. I think i cant extract the header of ppt file.

The downloading and uploading of a ppt file should be no different than the downloading and uploading of an image file; same principles.

The tutorial gives you the tools needed to upload a file and download a file.
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#8: Jul 7 '08

re: ppt file upload and download


Do not double post.
Reply