Jump to content

Recommended Posts

Hi guys Im new here. Ive got a small problem. I have a simple uploading script, had problems with that too but its working fine now to a certain extent. When I set a download link for the files that have been uploaded and click to download, it downloads but I get the following errors when I open the file, its a .txt file. But it seems to happen on all files also, it allows me to download .png, .php, .jpg bout it wont actually open them once they are downloaded  (Ive change the domain to an example, its not my actual domain within the warnings below):

 

The following warnings occurred:
Warning [2] filesize() [function.filesize]: stat failed for http://mydomain/expiry_files/downloads/text.txt" - Line: 69 - File: expiry_download.php PHP 5.2.17 (Linux)

 

Warning [2] readfile(http://mydomain/expiry_files/downloads/text.txt") [function.readfile]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found - Line: 70 - File: expiry_download.php PHP 5.2.17 (Linux)

 

 

 

Here my download file, most of it  (Ive also attached an image of the text file after I downloaded it and opened it, below):

 

if (isset($_GET['id'])){
		$file_id = (int)$_GET['id'];			
		$file = $db->query("SELECT * FROM ".TABLE_PREFIX."expiredownloads WHERE `id` = {$file_id}");

			$row = $db->fetch_array($file);

			if ($row['expire_end'] < time()){

					//// Do nothing Yet

				}else{
			    
                                        $link = ''.$mybb->settings['bburl'].'/expiry_files/downloads/'.$row['expire_file'].'"';
				$filename = $row['expire_file'];		
				header('Content-type: application/octetstream');
				header('Content-type: application/octet-stream');
				header('Content-Description: File Transfer');
				header("Content-Disposition: attachment; filename=\"$filename\"");
				header('Content-Length:'.filesize($link));
				readfile($link);
				}
			}

 

Hope you guys can spot a problem, If you require anymore information, just shout. Thanks in advance.

post-130774-13482403158787_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/254593-readfile-problems/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.