dear all
i'm trying to upload a file
but it seem i cant copy it to the destination folder
for infomation:
[root@batur image]# ll | grep test
total 32
drwxrwxrwx 2 apache apache 4096 Sep 18 11:51 test
[root@batulayang image]# pwd
/var/www/html/upload/image
[root@batur image]# cd test/
[root@batur test]# pwd
/var/www/html/upload/image/test
===
here's my code:
<?
$filename = $id.'-'.$HTTP_POST_FILES['userfile']['name'];
$max_size = 1500000; //maximum filesize
//------------------------------------------------------------------------------------
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
echo "File size is bigger than maximum size";
exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) {
echo "file already exist"; exit; }
$res = @copy($HTTP_POST_FILES['userfile']['tmp_name'],$path.$filename);[B]//it always failed to copy[/B]
if (!$res) {
echo "Copy failed";
exit;}
else {
echo "Copy success";
}
?>