#1  
Old 10-03-2005, 12:16 PM
Opshn Opshn is offline
Knight
 
Join Date: Jul 2005
Posts: 117
Opshn is on a distinguished road
Default

So I could ask this on a forum for php but I figure I would ask my friends here at Photics.com first.

On my web server I have some files that are stored as one file extension .tst and I want my people to be able to open them from a web link but the problem is that the files true format is varied. They are things like .pdf, .tif, .jpg, .bmp, etc. I was thinking at first I would use the php copy function to put the file on the users internet temp directory and then rename the file but then I was only able to make a copy from my web server to my web server. I tried php tmpfile and tempnam but perhaps I am not getting the concepts correct. What I really want to do is just use the original file name and extention to tell the web server to open the stored file as example.jpg instead of 1.tst
Reply With Quote
  #2  
Old 10-05-2005, 01:44 PM
eagle eagle is offline
Neophyte
 
Join Date: Jun 2005
Posts: 8
eagle is on a distinguished road
Default

Your PHP need to set the Content-type header before return the *.tst file content. Here is list of known content-type you can use:

text/richtext
text/html
audio/x-aiff
audio/basic
audio/wav
image/gif
image/jpeg
image/pjpeg
image/tiff
image/x-png
image/x-xbitmap
image/bmp
image/x-jg
image/x-emf
image/x-wmf
video/avi
video/mpeg
application/postscript
application/base64
application/macbinhex40
application/pdf
application/x-compressed
application/x-zip-compressed
application/x-gzip-compressed
application/java
application/x-msdownload
Reply With Quote
  #3  
Old 10-05-2005, 08:12 PM
Opshn Opshn is offline
Knight
 
Join Date: Jul 2005
Posts: 117
Opshn is on a distinguished road
Default

I wish it were that easy for me. I have tried to modify the content-type though as follows:

pure html:
Code:
<html>
<head>
  <meta http-equiv="content-type" content="application/pdf">
  
  <title>Doc Image Example</title>
</head>
<body>
[img]6.tst[/img]
</body>
</html>
pure php:
Code:
<?php
  header("Content-type: application/pdf"); //also tried: header("Content-type: application/pdf";);
  //and header("Content-type: application/pdf"; charset=utf-8);

  $filename = "6.tst" ;
  $dataFile = fopen( $filename, "r" ) ;

  if ( $dataFile )
  {
   while (!feof($dataFile))
   {
       $buffer = fgets($dataFile, 4096);
       echo $buffer;
   }

   fclose($dataFile);
  }
  else
  {
   die( "fopen failed for $filename" ) ;
  }
?>
the real problem is not getting the tst extension to open as a jpg but rather getting it to open as a tif. I can open it based on the original file name using RnOS ezpdf as a pdf file, but I haven't figured out a way to open the tif files in a web browser.
Reply With Quote
  #4  
Old 10-10-2005, 01:05 PM
Opshn Opshn is offline
Knight
 
Join Date: Jul 2005
Posts: 117
Opshn is on a distinguished road
Default

Just in case anyone is reading this thread. I am not sure what I was doing wrong... maybe my local pc needed a reboot or something but the content-type did in fact work for pdf and tiff but I just couldn't seem to get it to show at first.

Code:
<?php
  header('Content-type: image/tiff');
  $fn="3.tst";
  readfile($fn);
?>
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


Portions of this website are part of the Guild Wars Fansite Program. Guild Wars is a trademark of NCsoft Corporation. All rights reserved. Arena.net, ArenaNet and the ArenaNet logo are trademarks or registered trademarks of NCsoft Corporation in the U.S. and/or other countries. The Photics.com webserver is powered by HostRocket.
All times are GMT -4. The time now is 12:05 AM.

Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.