Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-06-2005, 10:53 AM   #1 (permalink)
fp_unit
mike
 
Join Date: Jan 2005
Location: Ottawa, ON
Posts: 79
fp_unit is on a distinguished road
Downloading files with PHP

I'm in the process of contemplating a switch from Perl to PHP for this project we're working on. Its a document producer tool for our website - we need to host a bunch of documents in our database and when documents are uploaded in the producer tool, they automatically display on the website. I'm kind of the lead programmer on this project (OK - the only programmer) and I have a good idea how to go about doing it, but I think it would be easier to maintain down the road if I use a language with much better OO support (php). OO in Perl is weird, and I'm not going to lie and say I know how to design procedural systems well - I dont.

So my question about PHP is: how would I go about downloading files over the Internet? In Perl we used the wget() series of utilities and I'm wondering what the equivalent is in PHP4 or 5 (preferably at least PHP-4.3.xxx). I need a way to pass an HTTP or FTP URL such as http://random.website.org/path/file.pdf and have this function download the file to where I tell it, such as /var/docs/only_writable_directory/company and report back results to me.

Thanks
fp_unit is offline   Reply With Quote
Old 07-06-2005, 11:45 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
You might want to use something like a combination of fopen(), fread(), fwrite() and fclose() for support on every php version.
There are functions like file_get_contents() and file_put_contents() or stream_get_contents() but they are not supported on older php versions.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-06-2005, 01:52 PM   #3 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
PHP 4's object support isn't any better than perl's just superficially easier to use. If you're definitely going to use php make sure you go with php5. Also, if you use php as the display layer, there's no reason you have to discontinue using perl for your data gatthering needs. The database and file system can act as the glue between the languages in your application.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 07-06-2005, 04:07 PM   #4 (permalink)
fp_unit
mike
 
Join Date: Jan 2005
Location: Ottawa, ON
Posts: 79
fp_unit is on a distinguished road
After more reading I agree about the object support in PHP4 - bleh. I'd definately install PHP5, I'd just have to be really careful, I dont want to be the IT guy who screws up the webserver

Its now a tossup between PHP5 and Java Servlets - I like the type safety of Java but I like the easy configuration of PHP. I'm laying out the design solution now then I'll pick a language based on how much OO I'll actually need.

One more question - if anyone knows, how is the support for polymorphism in PHP5?
fp_unit is offline   Reply With Quote
Old 07-06-2005, 04:29 PM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
PHP5 has a lot more OO support than PHP4, but it is still not a strongly typed language. Wouldn't this mean that polymorphism isn't really anything to consider with PHP?

And as for the java servlet thing, .. I think PHP is by far a more efficient tool to develop, deploy, and maintain web applications with. ( especially if you come from a perl background ) .. Just opinion though =)
__________________
Mike
sde is offline   Reply With Quote
Old 07-08-2005, 10:50 AM   #6 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Actually if you're looking for a language with the power of perl but good object features, you should check out Ruby. In Ruby everything even strings are objects. Also many people are saying good things about the web framework for Ruby called Ruby on Rails.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 07-08-2005, 11:00 AM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Man, It's been ages since I last used Ruby... It kinda reminds me of ADA.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-08-2005, 11:03 AM   #8 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Quote:
It kinda reminds me of ADA.
Cool and top secret?
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 07-08-2005, 11:23 AM   #9 (permalink)
fp_unit
mike
 
Join Date: Jan 2005
Location: Ottawa, ON
Posts: 79
fp_unit is on a distinguished road
Quote:
Originally Posted by teknomage1
Actually if you're looking for a language with the power of perl but good object features, you should check out Ruby. In Ruby everything even strings are objects. Also many people are saying good things about the web framework for Ruby called Ruby on Rails.
I want something that people can understand after I leave. If I had it my way I would just write my CGI's in C++ and download some Apache mods to keep the binary cached in the server.

Anyways this projects out the window for a while, some jerk rooted our server and deleted our website
fp_unit is offline   Reply With Quote
Old 07-08-2005, 11:25 AM   #10 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Quote:
Cool and top secret?
Nah, rather that everything is it's own object, only difference is that in the ADA object style, everything has it's own semaphore.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-08-2005, 11:31 AM   #11 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Quote:
If I had it my way I would just write my CGI's in C++ and download some Apache mods to keep the binary cached in the server.
If you like, I have some cool routines written in C, which fetches any POST or GET value and gathers it in a 2Dvector like structure.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic CSS files with PHP metazai PHP 28 06-28-2005 10:30 AM
PHP 5.0.4 and 4.3.11 Released sde Code Newbie News 0 04-20-2005 10:56 AM
PHP vs .NET Redline Lounge 1 11-24-2004 06:10 AM
Installing and using CMUgraphics library. Valmont Standard C, C++ 12 03-29-2003 08:39 AM


All times are GMT -8. The time now is 11:22 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting