From 48aa3737149e206919afb71fa98f283b2bcd4133 Mon Sep 17 00:00:00 2001 From: westi Date: Thu, 13 Aug 2009 20:31:12 +0000 Subject: [PATCH] Enable the APP attachment file download to work correctly rather than just returning a lot of php notices. Fixes #10372 for trunk props mysz. git-svn-id: http://svn.automattic.com/wordpress/trunk@11810 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-app.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wp-app.php b/wp-app.php index d6f67b9b0..69e50ab71 100644 --- a/wp-app.php +++ b/wp-app.php @@ -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;