]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-app.php
Wordpress 2.8.5
[autoinstalls/wordpress.git] / wp-app.php
index 0ada250e3aa73de4d81e303ea007474035aa811e..11f4ec77883fe647602531b68f7bb8519be28238 100644 (file)
@@ -780,6 +780,7 @@ EOD;
                }
 
                $location = get_post_meta($entry['ID'], '_wp_attached_file', true);
+               $location = get_option ('upload_path') . '/' . $location; 
                $filetype = wp_check_filetype($location);
 
                if(!isset($location) || 'attachment' != $entry['post_type'] || empty($filetype['ext']))
@@ -789,11 +790,19 @@ EOD;
                header('Content-Type: ' . $entry['post_mime_type']);
                header('Connection: close');
 
-               $fp = fopen($location, "rb");
-               while(!feof($fp)) {
-                       echo fread($fp, 4096);
+               if ($fp = fopen($location, "rb")) { 
+                       status_header('200'); 
+                       header('Content-Type: ' . $entry['post_mime_type']); 
+                       header('Connection: close');
+
+                       while(!feof($fp)) {
+                               echo fread($fp, 4096);
+                       }
+
+                       fclose($fp);
+               } else {
+                       status_header ('404');
                }
-               fclose($fp);
 
                log_app('function',"get_file($postID)");
                exit;