Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-02-2007, 06:43 PM
elle elle is offline
Newbie
 
Join Date: May 2007
Posts: 10
Rep Power: 0
elle is on a distinguished road
Default Downloading first n bytes of remote file

Hi there,

I need to download FIRST n bytes (n ~ 1024+^2) from remote file (located on the other server than mine). All must be done via fopen or similar functions and served to user via header function in binary mode. No redirection (Location via header allowed !

How's the best technique of that ?

It should be look like the code below. This code I'm using to retrieve data from the tail of the file :

Code:
<?php
	
	@ignore_user_abort();
	@set_time_limit(0);

	$name ='http://www.remoteserver.org/file.dat';
	$part_size = 1048576;

	$fp = @fopen($name, 'rb');
	
	@fseek($fp, -$part_size, SEEK_END);

	header("Content-Type: application/octet-stream");
	header('Content-Disposition: attachment; filename="file_part.dat"');
	header("Content-Length: ". $part_size);
	
	@fpassthru($fp);
	exit;

?>
TIA4NFO
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 08-03-2007, 08:48 PM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

I'm assuming you know n so you could set the header("size: ") to the answer of your equation.

P.S. - it may be "file-size"?
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-04-2007, 03:31 AM
Surgeon Surgeon is offline
Newbie
 
Join Date: Aug 2007
Posts: 3
Rep Power: 0
Surgeon is on a distinguished road
Default

You could use fgets to specify how many bytes to read from the file. May want to look into that

check out the PHP manual for fgets()
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 324 11-10-2008 08:34 PM
Project: ionFiles - Joomla Simple File Download - Mirror 2 Jordan ionFiles 6 11-06-2008 01:24 PM
File Manager Jaan Community Projects 45 08-27-2008 12:11 PM
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 04:22 PM
text file manipulations in vb6.0 Ronin_paes Visual Basic Programming 3 06-11-2007 05:54 AM


All times are GMT -5. The time now is 04:04 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads