Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Christian Weiske's Blog:
A MIME type for .php files
Apr 14, 2011 @ 14:17:06

Christian Weiske has a recent post to his site looking at something most PHP developers don't even think about when serving up their scripts - the MIME types for PHP files.

While setting some svn properties at work, we wondered about the correct MIME type for .php files.

He found several in the official IANA list including "text/php", "application/php" and "application/x-http-php" - all valid but none of them considered a standard. He talks about the ones supported by linux distributions (like Debian/Ubuntu) and some reasoning that might make "application/php" the best choice of the list. He points out some downsides to the choice, though, including the fact that something starting with "application/" should considered "machine readable" only despite PHP just being text.

tagged: mime type application text iana linux machinereadable plaintext

Link:

Sameer Borate's Blog:
Pushing xpi mime content from php
May 20, 2009 @ 12:06:09

In this new post to his blog, Sameer shows how you can push content with the xpi content type out from your PHP scripts (for things like a Firefox toolbar/extension).

A couple of days back I created a Firefox toolbar for my blog as an experiment in learning XUL. Once installed on my blog I wanted Firefox to recognize it as an addon and install it rather than displaying a ’save/open’ dialog.

Since his hosting provider (GoDaddy) didn't seem to work with adding it into an .htaccess file (an AddType for Apache), he had to force the download type with a few calls to header with the right content type, file size and file name to push it to the user.

tagged: firefox extension apache addtype mime xpi

Link:

NETTUTS.com:
How to Open Zip Files with PHP
Dec 31, 2008 @ 18:04:06

The NETTUTS.com site has a new tutorial/screencast posted looking at their method for opening up uploaded zip files with PHP:

ThemeForest has a nice feature; It allows the authors to upload zip files containing screenshots of their themes. A script then extracts these files and displays the images accordingly. Though I doubt that the developers used PHP to accomplish this task...that's what we're going to use!

They create a simple form with one field - a file input - and write some basic PHP around it. The script ensures that it was a zip file that was uploaded (based on the mime type) and passes it through a ZipArchive class to do the hard work. This class and the rest of the source can be downloaded from the site.

tagged: open zip file tutorial upload mime type download source

Link:

DevShed:
Migrating Class Code for a MIME Email to PHP 5
Aug 07, 2008 @ 16:16:43

DevShed has finished off their series looking at sending MIME emails with PHP in this new tutorial, moving the current code from the previous parts up to a fully PHP5 state.

While this mailer class can be used with small PHP applications, it lacks some important features related specifically to its object model, since it was built in PHP 4 from the very beginning.

They review the PHP4 version of the script first then move on to the process of porting it to a more standardized PHP5 structure and code.

tagged: mime email tutorial class php4 php5 migrate

Link:

DevShed:
Composing Messages in HTML for MIME Email with PHP
Jul 30, 2008 @ 19:34:59

DevShed continues its look at sending MIME emails with PHP in the fourth part of the series - a method for sending HTML in the message.

In this article, I'm going to show you how to provide the MIME mailer class with the ability to send email messages in HTML format. This will greatly extend its functionality, so don't miss this tutorial.

They start by reviewing the class they've created so far, including an example of its use. From there they modify it slightly to make it easy to embed the HTML content into the email by adding the addHTML and buildHTMLPart methods.

tagged: compose email tutorial mime html content

Link:

DevShed:
A Better Way to Determine MIME Types for MIME Email with PHP
Jul 24, 2008 @ 12:53:18

Continuing on in their look at sending MIME emails with PHP, DevShed has posted a better way for you to determine the correct MIME type of the file you're wanting to send (third part of the series).

I demonstrated how to build a modular MIME mailer class in PHP 4; it was provided with the capacity to send messages in plain text, and to work with different types of file attachments. This class implements a private method, called "getMimeTypes()," which, as its name would suggest, comes in handy for determining the correct MIME type of a given file. [...] However, the logic implemented by this method is rather primitive and can definitely be improved.

They start with a review of the previous code (PHP4) and show how to get the correct mime type of the file based on the extension mapped to an array of types.

tagged: mime tutorial type mail php4 class getmimetypes extension

Link:

Eran Galperin's Blog:
Handling mail and mime in PHP using the Zend Framework
Jul 18, 2008 @ 13:47:27

On the Techfounder blog (from Eran Galperin) there's a quick tutorial about using the Zend_Mail component of the Zend Framework to send both normal, plain-text emails and ones with MIME attachments.

Using PHP's built in function (aptly named mail() ) is relatively straightforward - until you need slightly more advanced features, such as adding and encoding email headers or sending multiple mails efficiently. Fortunately, the Zend Framework comes with a very capable mail component called Zend_Mail.

He shows how to send a simple email, do something a bit more complex with a custom SMTP server, read messages from a remote POP3 email box and how to attach a binary file/message.

tagged: zendframework email zendmail mime attachment pop3 read smtp custom

Link:

DevShed:
Handling Attachments in MIME Email with PHP
Jul 16, 2008 @ 17:58:17

DevShed has posted the second part of their series looking at handling MIME attachments in PHP generated emails today. This time they focus on the modification of their PHP4 class to make sending the emails easy.

In this second tutorial of the series, I'm going to teach you how to improve the initial structure of the MIME mailer class developed in the first article by giving it the ability to work directly with attachments. Sounds fairly interesting, right? Then don't waste any more time in preliminaries and begin reading this article now!

They refresh you on the code from the former tutorial and show you how to modify it to work with more than just the simple plain-text attachment like before (with binary information, things like JPEGs, PDFs and other text formats like XML and HTML).

tagged: attachments mime email tutorial class

Link:

DevShed:
Sending MIME Email with PHP
Jul 10, 2008 @ 13:49:20

In this new tutorial on DevShed Alejandro Gervasio explains how to send emails from PHP with MIME payloads attached.

One of the most common tasks that a PHP programmer has to tackle is the development of applications that send MIME email in one form or another. In simple terms, MIME email consists of an extension of traditional email technology and comes in handy for sending email messages in fancy HTML and handling file attachments in a wide variety of formats.

In this first part of the series he just lays the groundwork - creating the mailer class they'll use for the series and using it to send a sample email (a basic message with a plain text MIME block).

tagged: mime email tutorial payload class binary

Link:

DevShed:
Retrieving Information on Selected Files with a PHP 5 File Uploader
Mar 27, 2008 @ 14:31:04

DevShed has continued their series (here's part one) looking at the use of file uploading in your PHP scripts. They build on that foundation and add in some more useful features this time:

The initial script in the first tutorial of this series lacked some important features, such as the implementation of an effective error handling module and the ability to check the MIME type and size of the file being uploaded. In this second installment of the series, I'm going to improve the logic of the script from the first tutorial to provide it with the capacity to retrieve useful information concerning the entire file uploading process.

They look back at the previous tutorial to remind you of some of the concepts and then move on to show you how to get information about the file (like the MIME type, name and size of the uploaded file). The last page is just the full source code for the cut and pasters out there.

tagged: tutorial php5 file upload information mime name size

Link:


Trending Topics: