Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

Handling file uploads


Although most needs for data storage can be handled through the database, sometimes you will want to allow users to upload files to the server. Joomla! provides a library that makes it easy to safely handle file uploads.

For the Restaurant Reviews component, we want to make it possible for the critics to upload MP3 files to go with the reviews. To handle this, we need to adjust the form on which reviews are entered so that it accepts files. Also, the save() function in our controller for the backend needs to be adjusted to look for the file and copy it to the correct place.

First, open the file /administrator/components/com_restaurants/views/single/tmpl/default.php and make the following highlighted adjustments:

<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">

<fieldset class="adminform">
<legend>Details</legend>
<table class="admintable">
<tr>
<td width="100" align="right...