| View previous topic :: View next topic |
| Author |
Message |
computergeek67 Administrator


Joined: 31 Jul 2007 Posts: 144 Tokens: 147 Location: US
|
Posted: Tue Oct 23, 2007 4:58 pm Post subject: Create a Simple Form |
|
|
Forms are the fastest and easiest way to add interactivity to your site. I am going to teach you how to build a simple submit form. Paste this code: | Code: | <html>
<head>
<title>File Uploading Form</title>
</head>
<body>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="/php/file_uploader.php" method="post"
endtype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html> |
You will notice that it links to an external PHP file called "file_uploader.php". This is what file_uploader.php lookes like: | Code: | <?php
if( $_FILES['file']['name'] != "" )
{
copy( $_FILES['file']['name'], "/var/www/html" ) or
die( "Could not copy file!");
}
else
{
die("No file specified!");
}
?>
<html>
<head>
<title>Uploading Complete</title>
</head>
<body>
<h2>Uploaded File Info:</h2>
<ul>
<li>Sent file: <?php echo $_FILES['file']['name']; ?>
<li>File size: <?php echo $_FILES['file']['size']; ?> bytes
<li>File type: <?php echo $_FILES['file']['type']; ?>
</ul>
</body>
</html> |
Now when you upload a file, you should get the following result:
Uploaded File Info:
- Sent file: uploadedfile.txt
- File size: 2003 bytes
- File type: image/jpg
-Tutorialspoint.com
_________________
Come to me if you have any questions  |
|
| Back to top |
|
 |
evanescence Newbie

Joined: 28 Oct 2007 Posts: 12 Tokens: 12
|
Posted: Sun Oct 28, 2007 5:07 pm Post subject: |
|
|
ooh far too complicated for me lol!!!! _________________
 |
|
| Back to top |
|
 |
|