Upload File dengan PHP

Cukup sederhana kode untuk upload file di php. script untuk melakukan upload dengan php adalah seperti berikut ini. jangan lupa buat direktori uploads terlebih dahulu.

<!DOCTYPE html>
 <title>Upload your files</title>
 <form enctype="multipart/form-data" action="upload.php" method="POST">
 <p>Upload your file</p>
 <input type="file" name="uploaded_file"></input><br />
 <input type="submit" value="Upload"></input>
 $path = "uploads/";
 $path = $path . basename( $_FILES['uploaded_file']['name']);
 if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
 echo "The file ". basename( $_FILES['uploaded_file']['name']). 
 " has been uploaded";
 } else{
 echo "There was an error uploading the file, please try again!";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s