Uploading files with PHP

By December 21, 2011 PHP
Upload an image or file to your server without using your FTP.
Step 1: Open a web editor, then paste this
<form action=”upload.php” method=”post” ENCTYPE=”multipart/form-data”>
File: <input type=”file” name=”file” size=”30″> <input type=”submit” value=”Upload!”>
</form>
Then save it as form.php
Step 2: Open a web editor once again, and paste this code:
<?php
$uploaddir = “uploads”; // Where you want the files to upload to
if(is_uploaded_file($_FILES[‘file’][‘tmp_name’]))
{
move_uploaded_file($_FILES[‘file’][‘tmp_name’],$uploaddir.’/’.$_FILES[‘file’][‘name’]);
}
print “Your file has been uploaded successfully!”;
?>
Save it as upload.php
Step 3: Upload these to files onto your website using any ftp program.
Step 4: Upload a folder called uploads and CHMOD it to 0777

Leave a Reply

+ 29 = 38