the first thing its to make sure you have PHP on your webstie. if you don't, you can visit www.webune.com and signup with one of their PHP plans. I recommend them to all my customers, Webune has excellent service and support.
step 2 is to make open your favorite text editor. since i am using windows xp, i will be using notepad.exe
step 3 copy and paste the following code into a blank notepad:
Code:
<?
######################################################################
############ ############
############ Image Upload PHP Script by Wallpaperama.com ############
############ for help go to: http://www.wallpaperama.com ############
############ ############
######################################################################
?>
<html>
<head>
<title>Image File Upload With PHP Example Code By Wallpaperama</title>
</head>
<body>
<?php if (isset($_REQUEST['submit']))
{
echo"<h1>Image Upload Successfully!</h1><hr>";
?>
<p><img src="<? echo"images/$superdat_name"; ?>" ></p>
<p><em><strong>File Uploaded Location:</strong></em><br>
<input name="textfield" type="text" value="<? echo"images/$superdat_name"; ?>" size="100">
</p>
<p><a href="<?php echo $_SERVER['REQUEST_URI']; ?>">Upload Another Image >></a></p>
<p><strong>Help Us. If you learned from this script and would like to help us, please link to our site at :</strong> <a href="http://www.wallpaperama.com">http://www.wallpaperama.com</a></p>
<p><strong>If you would like to trade links with us, <a href="http://www.wallpaperama.com/link-exchange.php">click here</a></strong> <?
copy("$superdat", "images/$superdat_name") or die("Couldn't copy file.");
}
else
{
?>
</p>
<h1>Image File Upload With PHP Example Code By Wallpaperama</h1><hr>
<p>This is an example PHP script to show you how you can write a script to allow you or your visitors to be able to upload image files to your website. </p>
<FORM ACTION="<?php echo $_SERVER['REQUEST_URI']; ?>" METHOD="POST" ENCTYPE="multipart/form-data">
<CENTER>
<TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
<tr >
<td> </td>
<td> </td>
</tr>
<tr >
<td> </td>
<td> </td>
</tr>
<tr >
<td width=113>
<p align=right><b>Upload Image : </b> </td>
<td width=289>
<p><input type=file name="superdat" size=30></p>
</td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
</TABLE>
</CENTER>
<DIV ALIGN=CENTER>
<P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit" VALUE="Upload Image"></P>
</DIV>
</FORM>
<? } ?>
<p> </p>
<p align="center">Hosting And Support For This Script Provided By <a href="http://www.webune.com">Webune.com</a> </p>
</body>
</html>
######################################################################
############ ############
############ Image Upload PHP Script by Wallpaperama.com ############
############ for help go to: http://www.wallpaperama.com ############
############ ############
######################################################################
?>
<html>
<head>
<title>Image File Upload With PHP Example Code By Wallpaperama</title>
</head>
<body>
<?php if (isset($_REQUEST['submit']))
{
echo"<h1>Image Upload Successfully!</h1><hr>";
?>
<p><img src="<? echo"images/$superdat_name"; ?>" ></p>
<p><em><strong>File Uploaded Location:</strong></em><br>
<input name="textfield" type="text" value="<? echo"images/$superdat_name"; ?>" size="100">
</p>
<p><a href="<?php echo $_SERVER['REQUEST_URI']; ?>">Upload Another Image >></a></p>
<p><strong>Help Us. If you learned from this script and would like to help us, please link to our site at :</strong> <a href="http://www.wallpaperama.com">http://www.wallpaperama.com</a></p>
<p><strong>If you would like to trade links with us, <a href="http://www.wallpaperama.com/link-exchange.php">click here</a></strong> <?
copy("$superdat", "images/$superdat_name") or die("Couldn't copy file.");
}
else
{
?>
</p>
<h1>Image File Upload With PHP Example Code By Wallpaperama</h1><hr>
<p>This is an example PHP script to show you how you can write a script to allow you or your visitors to be able to upload image files to your website. </p>
<FORM ACTION="<?php echo $_SERVER['REQUEST_URI']; ?>" METHOD="POST" ENCTYPE="multipart/form-data">
<CENTER>
<TABLE WIDTH=450 BORDER=0 CELLPADDING=0 CELLSPACING=0 id=news>
<tr >
<td> </td>
<td> </td>
</tr>
<tr >
<td> </td>
<td> </td>
</tr>
<tr >
<td width=113>
<p align=right><b>Upload Image : </b> </td>
<td width=289>
<p><input type=file name="superdat" size=30></p>
</td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
</TABLE>
</CENTER>
<DIV ALIGN=CENTER>
<P STYLE="margin-bottom: 0in"><INPUT TYPE=SUBMIT NAME="submit" VALUE="Upload Image"></P>
</DIV>
</FORM>
<? } ?>
<p> </p>
<p align="center">Hosting And Support For This Script Provided By <a href="http://www.webune.com">Webune.com</a> </p>
</body>
</html>
step 4 save this file as upload.php (if you are going to be using notepad like i am, make sure when you save it put quotes like this: "upload.php" otherwise, notepad will save the file as notepad.php.txt)
step 5. FTP to your website and create a directory (folder) called upload.
step 6. once you have created a directory called "upload" (withoug quotes) upload the upload.php file to this new directory.
step 7. now create a new directory called image and make sure you give it write permission of 777. if you dont' do this step, the file will never upload to your website and this script is not going to work. and you will get an error
step 8. now you should have a file called upload.php and a directory called images in the upload directory. Open the upload.php file with your browser (example: http://www.yourdomain.com/upload/upload.php and try uploading an image. try uploading a small .gif or .jpg or .jpeg file.
step 9. if everything goes well, you should have an image file in the images directory
NOTE: this is a very basic script. there are other things you should use to make it more secure, like only allowing image files and limiting the image size for example, but that's another tutorial, the purpose of this tutorial was to teach you or give you and idea of how it works. later you can customize it and make it more secure and perhaps post your code ont his thread to share your knowledge with other just like i am doing today with you.
DONE
