Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Downloading Contents Of A Website


What would be the best way to download the contents of a particular website and define all the content/html as a variable? I'm currently using fopen / fread right now but there is a problem, the script will stall when its reading a missing file (404).

Is there a more efficient method besides using fopen / read? If not, is it possible to have the script error when there is a 404?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Refer To A File Outside The Website Tree For Downloading Purposes
I'm using Linux Redhat 8.0 (LAMP).
I have a file tx.zip , that is placed in /tmp.
Now I want people to be able to download this file without copying it to
the website tree
Can I make a reference like http://www.website.com/../../../tmp/tx.zip
if the root of my website is /var/www/html/Vwebsite ?
Due to restrictions, I cannot copy the file to /var/www/html/Vwebsite

Change Website To Php,mysql Data-driven Website
At the moment this site is not completely php. How can I make the content of the pages be from a mysql database? and how do I make the nav buttons work correctly connecting to the mysql database and displaying the correct content, ?

How To Upload File From Website To My Website?
I want to make upload page. I could upload file from computer to my website. But I don't know how to upload file from website to my website? How can I make it?

Downloading A .gif
I have a page with lots of thumbnails of photos. I want the user to be
able to dload a big version of the photo (also present on the server)
by either

1) clicking on it (left mousebutton) and have a 'save as...' dialog
or
2) right-clicking on it and have a 'save as...' dialog. But I don't
want the the whole photo to dload to the user before he is able to
rightclick it.

displaying the big photos as thumbnail and then right-clicking them is
not an option since it takes ages for a page with thumbanils to build
up...

I am not sure if 1 is possible and not sure if 2 is possible... Can
anyone give me a hint?

Downloading
I am cuurently trying to learn php and have created a site with an upload file facility, when they upload the file, my php script saves it on the server in a folder i dont wish to expose to anyone. now i need this folder to stay secret and not to allow the uploader to know what the new name of the folder is, this is all done.

But when a person searches my site for uploads by keyword or description (which the original uploader set) and finds one he wants to download how can i create a script that allows them to download it but not show the path of the file they are downloading.

Downloading A Site
In php, is there anyway to download the HTML contents of a given site and store it in a variable for parsing?

IE "download the msn.com HTML into $html_var and do this parsing code on it" ?

Downloading Pictures
I'm trying to download a gif image from the web and save to my servers hard drive. But I can't seem to fetch it correctly. I'm trying with.

Downloading Files Through Php
I am creating a site that will allow me to download files from my computer through the web. The problem I am having is that these files are not within the websever's root directory, so I need to use a php command to read them from another directory. I gave the webserver permissions on the shared directory and I can view text files with the fopen command. What I need to do is be able to download binary files. I don't know what the command to do this would be as fopen and readfile will only display the file in a brower window and this doesn't work for binary files.

Downloading File
I was trying to download a file which I have created in the server. I was successful enough to retrieve it by using the header function but unfortunately, the content has been changed. Instead of the data that I inserted in it, it was changed into a html codes.


Downloading Counter
I just wanted to ask if it is possible to have a download counter wherein the counter adds 1 whenever theres is a successful download, not when the user click on the download button?

Downloading A File
How would I let someone download a file blah.extension, where the file contains something that is made in the script? For example:

Grab database info
Make coding
Send it as blah.extension

I don't know how to send it as blah.extension, I've tried header type, but I'm not sure how to get the exact extension.

PHP-FTP Downloading Files
I am trying to download a file to my local machine using PHP. However, when
the script runs the file is placed in the folder assigned to the ftp user on
the Web server instead of downloading to my local C drive. After the
following script runs I find a file named C:TestShowID.txt in the user's
FTP folder on the web server. Can some tell me why this happens? The local
machine is a Windows XP machine.

$ftp = (object) array(
"host" = "ftp.mydomain.com",
"user" = "user@mydomain.net",
"password" = "password",
"remoteFile" = "ShowID.txt",
"localFile" = "C:TestShowID.txt"
);
// Step one: Connect to the FTP server
if(!is_resource($remoteRsrc=@ftp_connect($ftp->host)))
trigger_error("Could not connect to remote "
. "server {$ftp->host}", E_USER_ERROR );

// Step two: Log into the server
if( !@ftp_login($remoteRsrc,$ftp->user,$ftp->password))
trigger_error("Could not log on to remote "
. "server {$ftp->host}", E_USER_ERROR );

// Step Three: Attempt to copy remote file to local file
if(@ftp_get($remoteRsrc,$ftp->localFile,$ftp->remoteFile,FTP_BINARY))
echo "Remote file successfully written to {$ftp->localFile}";
else
trigger_error("Could not import remote file.",E_USER_ERROR);

// Step Four: Close the connection
ftp_close($remoteRsrc);

Uploading/downloading
I have made a database in mysql, and I can put files into it with a page wich is made with php. Uploading works, but not perfectly: files get damaged along the way.(for instance. I have a file 1229 bytes big, when I put it into the database it only is 1107 bytes big, and when I get it out of the database and save it onto my harddisk only 376 bytes remain).

Downloading Files
I need some code that will download a certain file, no matter what type it is. Currently, if it's say a .txt file it will open it in the browser, not download it. Is there a way to fix this in PHP?

Php Files Downloading
Can anyone suggest me why some .php files are downloading and some are
executing. Ive got php 5.2.0 and apache 2.0.54. Apache came as an rpm
along with Fedora 4. I downloaded php from the site and built it

Downloading Tif Files
how can this be done. if the href is to a *.zip file the "save as "prompt will open to prompt a download. so if a file is .tif. the browser will display this. what is the php code to do this simple task..?

Prevent Downloading
I recognized today that if I have an echo statement on an else at the end of
my script the only thing which was downloaded by wget was this string.

Is this a common way to prevent uncontrolled downoading of php scripts?

The software I wrote is GPL licensed so I would share it as package not as
partial files.





Ftp File Downloading...
im developing a site now... which capable of uploading files from client machine.. after downloading files... the creator/ client are capable of reviewing its uploaded documents.. guided by href links as a direct link to its file..... but my problem is how can i downloaded those files from the ftp?

i try href="/folder/file.doc"> file.doc [/url] == > but the browser says "The website declined to show this webpage"

Downloading A File
I do not have many experience with PHP.

What is the way to download a file? In my website I want to give
access to my users to downlaod several files.

PHP/XML And Downloading Files
I am trying to read in a few XML's from a couple different poker sites and then trying to parse them to display the latest tournaments that are going to be happening.  Is there any way I can just read in the file from http://tourneys.absolutepoker.com:8055/TourSchedule.xml to parse it.  Right now I can only figure out how to copy and paste the file onto my server and then open it from there.

Next, I am having problems parsing it.  I am putting each attribute into a two dimensional array when I am parsing it, but I cannot access thi sarray outside of the function.  I have the same echo statement inside the function and outside and it only prints it when it is inside the function. Code:

PHP Downloading Instead Of Compliling
I have a user who is using a script I edit, and this user is having troubles with php files being downloaded instead of parsed and output to the browser screen.

I have opened the page in several browsers, so it is not a browser problem, but it is very odd because some files are parsed as normal, and then others are not.  And it's not file specific, meaning that at one moment one file parses fine and another gets downloaded, and then at another time, the problem is the reverse.

I have many other users who use this same script and have no problems with the page being downloaded, so it must be box specific, but I have no idea what might be causing this extremely odd error. Code:

Automated Downloading Of Webpages
I'm doing a web programming project in my computer science course.
The task is to first create a content customizable webportal according to the user's preferences.

When a user login to the portal, the portal should be able to fetch the relevant information (webpages) and push it to the users.

The catch is, instead of just displaying those pages in the user's browser, I need the webportal to automatically DOWNLOAD all the pages to the user (save to the client-side).
Therefore, the user can read the information offline, reading form his/her own local disk.

This idea is similar to Avantgo for palm users.

Can I do this using PHP4 ? supported by perhaps Javascript ?
If anyone here know how to do this, please do let me know coz my deadline is very very near. So I'm desperate.

My focus is on the download mechanism. How to go about that.

Downloading A File...with Php3?
can anyone tell me how to download a file with php3 onto the server?

Downloading Or Uploading Progress
Hello world, i want to make module about downloading/uploading progress. May be somebody can tell me some tips?

I know what it's make on javascript, but how it transfers a file and show progress at the same time, like on rapidshare.com?

Create A Csv File On-the-fly For Downloading
I have a large database-created table on a page, that needs to have a "download as csv file" link (actually, as xcel, but I'll bet that's much harder to create).

What's the simplest way to do that? Do I actually delete-and-recreate a csv file on the server every time?

Downloading Exe File Does Not Work
I have a link in my page that allows users to download an exe file.
However, when I download and run it, it briefly displays the DOS box and
nothing happens. In my php file, I have:

header("Content-Type: application/octet-stream");
header("Content-Disposition: atachment; filename=$filename");
header("Content-Length: ".filesize("$path/$filename"));
header("Pragma: no-cache");
header("Expires: 0");
$fp=fopen("$path/$filename","r");
print fread($fp,filesize("$path/$filename"));
fclose($fp);
exit();

Am I missing something?

Also, if I click on the download again, after downloading it already, it
displays garbled text on the screen.

Uploading & Downloading Files
I know there have been quite a few posts about uploading and downloading files and I recently created a photo management program for a client who wanted to be able to upload his clients' tiff photos (some as large as 80MB) so his clients could download them. My webhost only allows so much uploading so I have only gone as far as uploading multiple files in one upload with a combined filesize of 17MB. I will be testing 50MB+ in the next few days so I will let you know if that works as well.

Anyway, I struggled with some of it and just wanted to share what I learned so that I can help some of you out. Here are my findings, I hope it helps...your mileage may vary.

1.) First off, I really had to massage the php.ini file on my virtual host account. I did this via .htaccess. That file now reads like this: PHP Code:

Downloading Php Code Instead Of File
I have a website where I can upload a file via a form. The uploaded
file is stored in a MySQL database. When dloading te file I get a save
as... dialog box, letting me save the file. But when it is dloaded and
I open it, it contains te HTML code of the file displayed...
Wordt thin g is - it _used_ to work so the code is OK - only some
little thing changed. Maybe the header part?

global $HTTP_GET_VARS, $connection;
$nodelist = array();
// Pull file meta-data
$SQL = "select * from filemetadata where id = '" .
$HTTP_GET_VARS[ID]."'";
if (!$result = mysql_query($SQL, $connection))
die("Failure to retrieve file metadata:L ".$php_error);

if (mysql_num_rows($result ) != 1)
die("Not a valid file id!");

$FileObj = mysql_fetch_array($result);

// Pull the list of file inodes
$SQL = "SELECT id FROM filedata WHERE
Masterid='".$HTTP_GET_VARS[ID]."' ORDER BY id";

if (!$result = mysql_query($SQL, $connection))
die("Failure to retrieve list of file inodes");

while ($CUR = mysql_fetch_object($result))
$nodelist[] = $CUR->id;

ob_end_clean();
ob_start();

// Send down the header to the client
Header ( "Content-Type: ".$FileObj[Datatype]);
Header ( "Content-Length: ".$FileObj[Size]);
Header ( "Content-Disposition: attachment;
filename=".$FileObj[Name]);

// Loop thru and stream the nodes 1 by 1
for ($i = 0 ; $i < count($nodelist) ; $i++) {
$SQL = "select FileData from filedata where id =
'".$nodelist[$i]."'";

if (!$result= mysql_query($SQL, $connection))
die("Failure to retrieve file node data");

$DataObj = mysql_fetch_object($result);
echo $DataObj->Filedata;
}
}

Downloading Gz Compressed Files?
i have a short php script that creates a gz compressed file, but...
when i try to download it, internet explorer doesn't prompt me for a
download location, and then save it at that download location...
instead, it just opens it as it would any old text document... this
is not what i want it to do... i want to be able to download it, not
view it. any ideas on how to do this?

here's the code:

<?
system("ls -l | gzip > test.gz");
print "download <a href=test.gz>here</a>";
?>

Automatic File Downloading
When a user clicks on a certain link, the file opens when he has a registered program for that file type. For example: if I click on a link to a .doc-file, it opens in Word, if I click on a .gif-file, it opens in my browser.

Does anyone know how to download a file automatically, no matter what programs are installed, so that even .html-pages are downloaded in stead of shown? Guess it can be done by sending an alternative header with the file, but don't know how to do it exactly.

Downloading Files [mp3's]
I'm trying to write a scipt that downloads files when a link is clicked. Ive searched through the forums but all results are about headers. The link provides a $id and the script queries the DB for the file name [$file]. The script doesnt seem to be picking up the filename and instead is calling it 'Resource id #4'. Heres the script: PHP Code:

How To Redirect After Downloading Files
I have a download files source code which may be the same with others as far as I have searched. Code:

$myfile = "arrow.gif";
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($myfile).";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($myfile));
readfile("$myfile");
echo "hello";

THe code works, but I want to display the message hello after downloading, or redirect to another page, but it doesnt work. After downloading the file, it stops the execution of script. I already deleted the exit() function at the last line.

Downloading An Uploaded .doc File
I am working on a site in which some members may browse/upload a Word document and other members may wish to download these and view them. I have tried saving the uploaded file like..

if (!copy($cv, "cvs/cv".$cid.".doc") ) {
echo("Problems encountered receiving your CV. However your application will still be processed.");}

and the download link like...

<A HREF='<?="/cvs/cv$cid.doc"?>'><B>View</B></A>

..and the browser opens Word and the file gets displayed. This is taking FAR to long to happen. What would be ideal is to simply click on the link and get the normal download dialog up. I also tried..

if (!copy($cv, "cvs/cv".$cid) ) {
...} and to view..

<A HREF='<?="/cvs/cv$cid"?>'><B>View</B></A>

..but I got a download dialog asking if I wanted to download CVxxx.txt but I need CVxxx.doc. Any ideas? I want to be prompted to download a Word Doc.

Downloading Secure Documents
i'm building a site which will have a secure section (still haven't decided between cookies and sessions), but anyhow, after the login screen, there will be links to a bunch of word documents that the user can download or view. I'm thinking anyone who knows the path to those documents can view them without logging in.. is there a way to prevent this? or am I just wrong?

Downloading Attachments From Mailclient
i try to download attachments from a mailclient, but it doesn't seem to work
somehow, the code adds 2 spaces in the beginning of the attachment for example the beginning of a jpg image, opened in notepad++ looks like this:

˙Ř˙ŕNULDLEJFIFNULSOHSOHSOHNUL`NUL`NULNUL and so on, what it means doesn't realy matter for me, what matters is that while downloading the image those 2 spaces you see come in front of it on the first row, so the image wount load anymore, unless i open it with notepad++ and remove the spaces. Code:

Characters Stripped When Downloading
I've made a special page for only downloading files. This is a private, protected page, so I can't give a link to it.

The problem is that some filenames contain non-latin characters which are stripped off, so the user doesn't get the complete name. Spaces are converted to underscores, but we can live with that. When characters disappear, it's another matter.

Downloading A Fraction Of The File
I ahve a download script that is only downloading a fraction of the file. can anyone point me to a tutorial/script that will enable me to understand headers and what is required.

Downloading And Parsing Web-stuff
Very basic:

What is the easiest way in php to download the source code (HTML etc.)
of a given URL (say, http://www.google.com) and parse this code for
certain patterns?

I guess my question can be split in two:

1) How do I download a webpage (into a string or whatever)?

2) How can I do string manupulation, regexp matching, information
extraction etc. on the downloaded information?


Certain Type Of Downloading Script
I am currently trying to make a website that facilitates a lot of downloading; but I want to control the amount of download that each user can have at a certain time. This way, I won't have to stress about server fees as much.

The script I am looking for is a downloading script that does a countdown to start a download. But the problem is, how would I make it so that the first download starts instantly, but the ones after that will have a 5 minute count down?

Downloading A File From Another Site
I want to be able to have a script on mysite(http://mysite.com) to download a file from another site(http://downloadsite.com).  I wrote a script where you enter the location of a file (http://downloadsite.com/song.mp3) and click "fletch file" it well get the file and allow you to download it.  But it takes forever it seems like it transfers to my websever first before the dialog pops up so i can download it.  Heres the code:

Downloading From Another Server(txt File).
Can someone tell me how I can get a txt file, or its contents this way:
Running a cron every 30 minutes, get file contents or download the txt file.
Save it on sever.

Downloading Only 100 Characters Of A Download.
I am writing a script that can determine whether a link is to a file or a html page. It is a linkchecker script.

I want to put in a url and it download and check the url for live or dead status. The only problem is that if a direct file link is put in it downloads the entire file onto my server before checking the contents.  I have almost gotten everything working except for the fact that some of these files are 100mb in size. 

I want to limit what my script downloads to check to about the first 50 characters of the file.  It will then use those 50 characters to determine whether or not that file is a html or a direct linked file.  This is what I have so far. Code:

Downloading Mails From Gmail
anybody here has downloaded mails from gmail account along with attachment.

Streaming Mp3s W/out Possibility Of Downloading
I'm trying to convert a script I created from streaming audio files via Real Audio to mp3 clips. Naturally, I want to prevent the user from being able to save the actual file to their computer. With Real Audio I can create a .ram file on demand using fwrite() and then header() to open the ram file.

I tried doing this w/mp3s by having the script create a m3u file. While this did stream the file, I could just right click on the link and download the m3u file, and see the source of the mp3 file by opening that m3u file with WordPad. How can I get around this? There are some applications that do this, but those that I've found were obviously made by someone who didn't think anyone would want to look at the code (ie. a million lines of code in one file)! Of course, I want to make my own script. Any ideas on how to design this script? Or at least where I could get more info on streaming mp3s? I've searched for answers, but came up empty.

Saving/downloading A Dynamic File
Is there a way of making a PHP script go to a URL, like
www.somedomain.com/file?id=2, and saving the dynamic file that is created?

I want to run this script in crontab, so it downloads the file every hour. I have tried using wget, but that doesn't seem to save the dynamic file created, it just saves the blank HTML page "file?id=2".

Code For Downloading Option Used In Websites
Most of the web sites offer a downloading options ( As we see in most of the
CMS ). On selecting a file, it asks where to download the file. I have tried
several ways, but none of them are working. Please help me, as i want to keep
this option in my site design.

Creating A Pseudo Filename For Downloading?
I have an interesting problem....

I work for a company that develops software for the building industry
and would like to distribute one of our software products via the
web.

here is the problem

The main file sits on my web server. We generate unique URLs for the
buyer to download the software. We also generate unique filenames and
store it in a database along with the unique URL This in essence is a
pseudo filename

When the user clicks on the URL that we send him I need the PHP
script to initiate the file transfer giving the user the pseudo
filename rather than the actual filename on the server

I have everything working except for the ability to send the user the
pseudo filename! at this moment in time we are sending them the same
filename as the file sitting on our server.

Is there anyway of doing this with PHP?

Edit: In my code I have tried the following

header('Content-Description: File
Transfer');
header('Content-Type: application/force-download'); //
Tells the browser to expect a download
header("Content-Transfer-Encoding: Binary"); //
Tells the browser the format of the data
header('Content-Length: ' .
filesize($realfilename)); // Tells the browser the size
of the file
header('Content-Disposition: attachment; filename=' .
basename($uniquefilename)); // Tells the browser the
name of the file

readfile($realfilename);

As you can see I am reading the original filename's properties however
using the Content-Disposition header to tell the browser the filename
to download!

Downloading From A Directory Not In The Server's Path?
Is there a way to download a file from a directory not in the server's
path? Eg. not under public_html? This would be for security so that
the files can never be directly access vial the web.

I did a search on PHP + download but this garnered many unless web
sites.

Block Someone Downloading S/t With A Direct Link?
is there a way that the server first checks if the user is allowed to download the file? maybe the server checks for a cookie or the url must have a session id that is being checked; when it's valid the download starts, when it's not valid there's an error screen?! is there a way? maybe with a .htaccess file with php codes in it?


Copyright © 2005-08 www.BigResource.com, All rights reserved