Nov 15

Permasalahan yang sering muncul saat upload file dan cara menanganinya.

Contoh skrip Upload PHP File Upload

<html>
<head>
<title>Contoh Form Upload dengan PHP</title>
</head>
<body>

Contoh Form Upload dengan PHP
<form enctype=”multipart/form-data” action=”upload.php” method=”post”>
<input type=”hidden” name=”MAX_FILE_SIZE” value=”15000000″ />
Upload this file: <input name=”userfile” type=”file” />
<input type=”submit” value=”Upload” />
</form>

</body>
</html>

File Upload.php

$uploaddir = ‘images/’;
$uploadfile = $uploaddir . $_FILES['userfile']['name'];
chmod(”$userfile”, 0644);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo “File $uploadfile sukses diupload”;
} else {
echo “Proses upload gagal, kode error = ” . $_FILES['userfile']['error'];
}
?>

TroubleShoot

Apa bila upload file gagal maka sebaiknya yang anda lakukan adalah

1. Pastikan quota atau hardisk anda masih mempunyai Free Space?
2. Pastikan Permisi folder tujuan anda writeable (dapat di tulisi - permisi file 777)
3. Pastikan konfigurasi PHP anda sudah pas dengan kebutuhan upload (PHP membatasi maximum size file yang di upload). Adapun variable-variabel yang harus diperatikan adalah

* file_uploads
* upload_max_file_size
* post_max_size
* memory_limit
* max_execution_time
* max_input_time

Sumber diambil dari wiki forum php

Topics: PHP Beginner |

Comments