#158688 - 02/05/2003 21:44
How does this work?
|
carpal tunnel
Registered: 08/03/2000
Posts: 12341
Loc: Sterling, VA
|
Two parts:
1) how do I upload a file to a server using PHP?
2) how do I read contents of a directory and generally look at files using PHP?
See, I've got this whole member database that I created with an enormous amount of help from people here, and I recently made it possible for people to update their information themselves, but the one thing they can't change is their pictures.
Currently the method is this: the person gives the webmaster (me, for now) a picture to use as their bio picture. I take that file, edit it to the size I want (all 200 pixels wide, any height). Then I put the file in a directory on the server. I name it using fields from that person's bio (ie: lastnamefirstname.jpg). The problem is two-fold. For one, the webmaster has to do all this, and I want the user to be able to. Two, if the user changes their name, the script that displays the picture is looking for a file based on their new name, not the old one.
Since I'm sure it's easier, simply renaming the file based on the newly entered information would solve the second problem. I don't know how to manipulate files with PHP, though. I also have no clue how to go about the first part.
Thanks in advance for the help. I tried looking for stuff like this in the online PHP manual, but it's a bit hard to decipher from that thing. What books would you all suggest?
_________________________
Matt
|
Top
|
|
|
|
#158689 - 02/05/2003 22:46
Re: How does this work?
[Re: Dignan]
|
old hand
Registered: 12/01/2000
Posts: 1079
Loc: Dallas, TX
|
Im no coder, but I would look at how others do it. phpbb has this avatar function built in, and it seems to work pretty well. http://www.phpbb.com
To manipulate the size of the picture, you will need to have the NetBPM library installed and running on the web server you are using.
When you start talking about letting users add files, then you will most likely have to disable some security features like safe mode.
Sorry about the non specific answer, but hopefully this will make you ask more questions and eventually lead to the correct answer.
Edited by Terminator (02/05/2003 22:54)
|
Top
|
|
|
|
#158690 - 02/05/2003 22:57
Re: How does this work?
[Re: Dignan]
|
carpal tunnel
Registered: 30/10/2000
Posts: 4931
Loc: New Jersey, USA
|
I have been using cPanel to setup simple web sites for the entire day today. In the program there is a file manager that is surprisingly capable. Upload files, change names, edit files, change permissions, etc.
Too bad the software costs $1400. If only you could get just that module.
PS- I just checked Freshmeat and found this
_________________________
-Rob Riccardelli 80GB 16MB MK2 090000736
|
Top
|
|
|
|
#158691 - 03/05/2003 01:16
Re: How does this work?
[Re: Dignan]
|
veteran
Registered: 19/06/2000
Posts: 1495
Loc: US: CA
|
I have a ton of stuff written which does things similar to what you're describing. Actually, the first thing you list is almost exactly what I have. Plus, I have the upload code from LRCdb. Anyway, I'll dig up my code when I get a chance and let you know when I can send it. Of course, you'd still have to do some modifications (if not heavy ones) to get it to work the way you want and with your setup, but it will give you a jumpstart, and a working example.
Ok, I've got it. It's code I hacked together in a few hours for Justin a while back. Not pretty, but it works. PM me with a place to send it.
Edited by ricin (03/05/2003 01:41)
_________________________
Donato MkII/080000565 MkIIa/010101253 ricin.us
|
Top
|
|
|
|
#158692 - 03/05/2003 20:48
Re: How does this work?
[Re: ricin]
|
veteran
Registered: 19/06/2000
Posts: 1495
Loc: US: CA
|
Ok, if you're wondering why it's taking me so long to get you the files, it's because I got into an accident today. Damn it. I've been talking to CHP, the insurance Company, and my dad (he's a Police Officer) since 2 O'clock when it happened. I'll try and get those files zipped up and sent off ASAP.
_________________________
Donato MkII/080000565 MkIIa/010101253 ricin.us
|
Top
|
|
|
|
#158693 - 03/05/2003 22:46
Re: How does this work?
[Re: ricin]
|
carpal tunnel
Registered: 08/03/2000
Posts: 12341
Loc: Sterling, VA
|
No, I insist that you get that code to me without regard for yourself!
By all means, take your time I'm still looking into the options.
Thanks to everyone who offered solutions. Most of them seem much more complicated than I need, but that may just be the way of it.
I tried just using the "copy" in PHP with a file form tag, but I got the error that permission was denied on the server. I saw some options for getting around this, although I don't know what causes the problem to begin with. If it had worked, I would have added the file checks and such, but I couldn't get the first step down.
*edit*
sorry, I forgot to change the permissions of the folders I was dealing with. I'm going to try again I've at least successfully renamed a file!
Edited by DiGNAN17 (03/05/2003 23:35)
_________________________
Matt
|
Top
|
|
|
|
#158694 - 05/05/2003 23:50
Re: How does this work?
[Re: ricin]
|
carpal tunnel
Registered: 08/03/2000
Posts: 12341
Loc: Sterling, VA
|
Thanks to all of you for giving me all this code. I didn't end up using it, but I read through it and it gave me a lot of info, which is just as usefull.
I ended up using another piece of code that I got somewhere because it was very simplistic. It merely uploaded the file and ran the most basic of checks that I needed.
One question, though, which isn't answered in the PHP manual:
Say I have this:
rename ("some/path/file.ext", "some/file.ext")
Does that, in effect, move the file, or simply create a new file in the different location?
_________________________
Matt
|
Top
|
|
|
|
|
|