PHP File Uploads
It's been five months since I last wrote an article for the LAMP area of this site. What have you guys been up to since? I know some of you took the bull by the horns and are now well versed in PHP. Were the rest of you waiting for me to get round to the "advanced" section? Well, I'm making a start on that now.
When I say advanced I am merely talking about things we take for granted with Domino. Attachments for example. Stick a File Upload Control on a form and you're done! In PHP it's not quite so easy. I've added a file upload to the PHP journal app.'s form and will start/finish an article some time this week, hopefully.
If you look at the form, notice that I've limited the size of uploads to 10KB. Remember this article I wrote a while back describing a way to do this with Domino? Wasn't easy was it! With PHP it's as simple as one line of code:
if ($HTTP_POST_FILES[ 'attachment' ][ 'size' ] > 10000 ) {
So, whereas, with Domino, it's easy to add the functionality as a whole, it's tricky to do anything beyond the basics. Don't let me get in to a whole "Isn't PHP better than Domino" speel. There's no point in that. It's a case of "horses for courses". Personally I prefer PHP, as you all know, because I can do what I like with it. There might well be some work up front but it's worth it. Plus, once you've coded the logic once you can use it over and over - maybe even writing a class to handle it all.
you can use $_FILES instead of $HTTP_POST_FILES since php 4.1.0, that's easier (and global arr)
Added a comment to your Domino article on the topic. You can also limit the upload size with one line of @code.
Thanks Niel. Added my reply.
While enjoying your LAMP stuff I am working through a Websphere book. I really like the Websphere Application Developer, it is really a step forward. You can always right-click and everything is done automatically. So you can concentrate on the logic and not on setting dots and braces and so on. Have you tried to code PHP with Eclipse? I think there are some nice plugins to do that.
Hadn't tried coding in Eclipse. Will have a go now... well, I got PHPEclipse {Link} up and running ok. Looks good. Shall see if it's any better to coding in Textpad.
sir i want coding for file uploading
or the proper guidence froom u
Jake,
I am working out a solution by implementing Uploadify in a Lotus Domino environment. Uploadify also uses PHP with $_FILES instead of $HTTP_POST_FILES. Currently i still cannot figure out how domino could get a handle to a simular to $_FILES.
The goal of the implementation of Uploadify in my case is to precheck the uploaded Filesize of an attachment before upload to the server.
Any suggestion is welcome.