Help needed in uploading file on server on a button click
Posted: Wed Jun 24, 2009 2:28 am
Hi everyone,
I want to upload a file on server through button click on a web page,its working on my localhost but when i try to upload the file on server i get following error,
Warning: move_uploaded_file(Document/CV/0[1].578125001245226128_Services2.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/content/o/p/t/opt4me/html/uploadCV.php on line 21
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpEaJk81' to 'Document/CV/0[1].578125001245226128_Services2.gif' in /home/content/o/p/t/opt4me/html/uploadCV.php on line 21
My code is:
I want to upload a file on server through button click on a web page,its working on my localhost but when i try to upload the file on server i get following error,
Warning: move_uploaded_file(Document/CV/0[1].578125001245226128_Services2.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/content/o/p/t/opt4me/html/uploadCV.php on line 21
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpEaJk81' to 'Document/CV/0[1].578125001245226128_Services2.gif' in /home/content/o/p/t/opt4me/html/uploadCV.php on line 21
My code is:
Code: Select all
<?php
include ('dbconnect.php');
$filename = $_FILES['userfile']['name'];
if($filename == '')
{
header('location: index.php');
}
else
{
$uploaddir = 'Document/CV/';
//chmod('777',$uploaddir);
$filename = $_FILES['userfile']['name'];
$fullfilename = $_FILES['userfile']['name'];
$uploadfile = $uploaddir.$fullfilename;
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
$query2 = "insert into table1(CV_name,CV_fulname,date) values ('$filename','$fullfilename',curdate())";
mysql_query($query2);
$insertId2 = mysql_insert_id();
if($insertId2)
{
header('location:regester_user.php?cvid='.$insertId2);
exit;
}
else
{
header('location: index.php');}
}
//end code of Upload File.
}
?>