PHP Image Read Issue -
i installing website on server, , seems have problem displaying images. when come in image url, first gives 200 response, see next in chrome debugger:
invalid / (failed) / net::err_failed
request url:chrome-extension://invalid/ request headers caution: provisional headers shown. referer:http://tema-arc.co.il/index.php?item=file&action=download/786 user-agent:mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/35.0.1916.114 safari/537.36 opr/22.0.1471.50 (edition campaign 47) x-source-map-request-from:inspector i have traced problem next function. in origin got content-length wrong, fixed, , next updated code.
the file exists; when seek output $sourcename, points real image file. $size right well. in fact, dimensions right, can "zoom in" in browser when go image url, image not displayed. needless have tried multiple browsers , multiple debuggers, chrome debugger gave thing resembling actual error.
function download($fileid) { $db = new database(); @clearstatcache(); $file = $db->table('cms_files')->where(array('fileid' => $fileid))->select(); $sourcename = config::get('uploadpath').$file[0]['source']; if (!count($file) || !file_exists($sourcename)) { $this->application->setnotfound(); exit; } $size = filesize($sourcename); $type = $file[0]['type']; $name = $file[0]['name']; $lastmodified = filemtime($sourcename); header('content-description: file transfer'); header('content-type: '.$type); $ua = $_server['http_user_agent']; if (0 !== strpos($ua, 'mozilla/4.0 (compatible; msie ') || false !== strpos($ua, 'opera')) { header('content-disposition: inline; filename="'.str_replace('"', '', basename($name)).'"'); } else { header('content-disposition: inline; filename="'.mb_convert_encoding(str_replace('"', '', basename($name)),"iso-8859-8", "auto").'"'); } header('content-transfer-encoding: binary'); header('cache-control: max-age=604800'); // cache 1 week. header('last-modified: '.gmdate("d, d m y h:i:s",$lastmodified) . " gmt"); $iflastmodified = isset($_server['http_if_modified_since']) ? strtotime($_server['http_if_modified_since']) : false; if($iflastmodified !== false && $lastmodified <= $iflastmodified) { header('http/1.0 304 not modified'); } else { header('content-length: ' . $size); ob_clean(); flush(); readfile($sourcename); } exit; } php image
No comments:
Post a Comment