the code is what I currently have for the THEME folder for Drupal page. Line 39-45 is what I wrote for the uploading file part.
Expand|Select|Wrap|Line Numbers
- <?php
- // $Id: page.tpl.php,v 1.28.2.1 2009/04/30 00:13:31 goba Exp $
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language ?>" xml:lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
- <head>
- <?php print $head ?>
- <title><?php print $head_title ?></title>
- <?php print $styles ?>
- <?php print $scripts ?>
- <script type="text/javascript"><?php /* Needed to avoid Flash of Unstyle Content in IE */ ?> </script>
- </head>
- <body>
- <table border="0" cellpadding="0" cellspacing="0" id="header">
- <tr>
- <td id="logo">
- <?php if ($logo) { ?><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>
- <?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
- <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
- </td>
- <td id="menu">
- <?php if (isset($secondary_links)) { ?><?php print theme('links', $secondary_links, array('class' => 'links', 'id' => 'subnavlist')) ?><?php } ?>
- <?php if (isset($primary_links)) { ?><?php print theme('links', $primary_links, array('class' => 'links', 'id' => 'navlist')) ?><?php } ?>
- <?php print $search_box ?>
- </td>
- </tr>
- <tr>
- <td colspan="2"><div><?php print $header ?></div></td>
- </tr>
- </table>
- <table border="0" cellpadding="0" cellspacing="0" id="content">
- <tr>
- <?php if ($left) { ?><td id="sidebar-left">
- <?php print $left ?>
- <form action="test_0512.php" method="post"
- enctype="multipart/form-data">
- <label for="file">Upload the file: </label>
- <input type="file" name="file" id="file" />
- <br />
- <input type="submit" name="submit" value="Submit" />
- </form>
- </td><?php } ?>
- <td valign="top">
- <?php if ($mission) { ?><div id="mission"><?php print $mission ?></div><?php } ?>
- <div id="main">
- <?php print $breadcrumb ?>
- <h1 class="title"><?php print $title ?></h1>
- <div class="tabs"><?php print $tabs ?></div>
- <?php if ($show_messages) { print $messages; } ?>
- <?php print $help ?>
- <?php print $content; ?>
- <?php print $feed_icons; ?>
- </div>
- </td>
- <?php if ($right) { ?><td id="sidebar-right">
- <?php print $right ?>
- </td><?php } ?>
- </tr>
- </table>
- <div id="footer">
- <?php print $footer_message ?>
- <?php print $footer ?>
- </div>
- <?php print $closure ?>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <title>TESTING PAGE</title>
- </head>
- <body>
- <?php
- $file = $_FILES['fileHandle']['name'];
- move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
- "C:/upload/" . $_FILES["fileToUpload"]["name"]);
- if ($_FILES["fileToUpload"]["error"] > 0)
- {
- echo "Apologies, an error has occurred.";
- echo "Error Code: " . $_FILES["fileToUpload"]["error"];
- }
- else
- {
- move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
- "C:/upload/" . $_FILES["fileToUpload"]["name"]);
- }
- //$file = fopen($fileName, "r") or exit ("Unable to open file!");
- while(!feof($file))
- {
- $line = fgets($file); // Read a line.
- //escape if the line is empty
- if (trim($line) == "")
- continue;
- //explode from the :
- $fields = explode(":", $line, 2);
- echo "<b>$fields[0]</b>";
- //checks if second part exists
- if (isset($fields[1]))
- echo " : $fields[1]";
- echo "<br/>";
- }
- fclose($file);
- ?>
- </body>
- </html>