Jump to content

Uploading Files To File Server Using PHP


deepurushotham

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.