Create Simple Upload Form with PHP

Last week, I have a task to create upload system from my friend. I gave her a simple form to upload file to her web directory. It works to get selected file from your computer and try to upload it to your web directory. I used XAMPP for this project before make it online.

  • create new directory in htdocs folder. I named it upload.
  • Open that directory and create new file called “form.php”. Insert code above inside form.php
 <body><h1>Test upload and listing directories</h1>

<form enctype="multipart/form-data" action="upload.php" method="POST">
 Pilih file:
 <input name="uploaded" type="file" /><br />
 <input type="submit" name="upload" value="Upload" />

  • Now, create new file called “upload.php”. This file contains code to upload a file to web server.
$target = "file/";
$target = $target . basename($_FILES['uploaded']['name']);
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
echo "The file ". basename($_FILES['uploadedfile']['name']). "has been uploaded";
echo "Data gagal disimpan.";

  • Last step, create new folder called file at the same directory.

Save all of your changes and type http://localhost/upload/form.php to try upload a file into your directory.

Satu respons untuk “Create Simple Upload Form with PHP

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s