deepurushotham Posted March 29, 2008 Share Posted March 29, 2008 Hi Guide.. I Have a problem in uploading files. The code i have used is <? // you can change this to any directory you want // as long as php can write to it $uploadDir = 'E:\Resume'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; // the files will be saved in filePath $filePath = $uploadDir . $fileName; // move the files to the specified directory // if the upload directory is not writable or // something else went wrong $result will be false $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } include 'config-1.php'; include 'opendb.php'; if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = "INSERT INTO upload2 (name, size, type, path ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); include 'closedb.php'; echo "<br>File uploaded<br>"; } ?> Connection to database is perfect. The error i am getting is Warning: move_uploaded_file(E:\Resumeup.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/sennall/public_html/Payroll/upload2.php on line 38 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpKqB0b6' to 'E:\Resumeup.txt' in /home/sennall/public_html/Payroll/upload2.php on line 38 Error uploading file Can anyone help me in solving this or what can i do to upload files corectly.. Thanks... Link to comment https://forums.phpfreaks.com/topic/98449-uploading-files-to-file-server-using-php/ Share on other sites More sharing options...
Barand Posted March 29, 2008 Share Posted March 29, 2008 looks like you are missing "\" between uploaddir and the filename Also it's easier to use / rather than \ (as \ is the escape character) Link to comment https://forums.phpfreaks.com/topic/98449-uploading-files-to-file-server-using-php/#findComment-503868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.