PHP Error - Uploading a documents

I'm attempting to write some PHP to upload a documents to a folder on my webserver. Below's what I have:

<?php
    if ( !empty($_FILES['file']['tmp_name']) ) {
        move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']);
        header('Location: http://www.mywebsite.com/dump/');
        exit;
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
    <head>
        <title>Dump Upload</title>
    </head>
    <body>
        <h1>Upload a File</h1>
        <form action="upload.php" enctype="multipart/form-data" method="post">
            <input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
            Select the File:<br /><input type="file" name="file" /><br />
            <input type="submit" value="Upload" />
        </form>
    </body>
</html>

I'm obtaining these mistakes:

Warning : move_uploaded_file (./ test.txt) [function.move - posted - documents ] : fell short to open stream : Permission refuted in E :\ inetpub \ vhosts \ mywebsite.com \ httpdocs \ dump \ upload.php on line 3

Warning : move_uploaded_file () [function.move - uploaded - documents ] : Unable to relocate 'C :\ WINDOWS \ Temp \ phpA30E.tmp' to './ test.txt' in E :\ inetpub \ vhosts \ mywebsite.com \ httpdocs \ dump \ upload.php on line 3

Warning : Can not change header details - headers currently sent out by (result begun at E :\ inetpub \ vhosts \ mywebsite.com \ httpdocs \ dump \ upload.php :3) in E :\ inetpub \ vhosts \ mywebsite.com \ httpdocs \ dump \ upload.php on line 4

PHP variation 4.4.7 Running IIS on a Windows box. This certain file/folder has 777 approvals.

Any kind of suggestions?

0
2019-05-09 11:01:49
Source Share
Answers: 3

Try including a course. The adhering to code benefit me:

<?php

if ( !empty($_FILES['file']) ) {
    $from = $_FILES['file']['tmp_name'];
    $to = dirname(__FILE__).'/'.$_FILES['file']['name'];

    if( move_uploaded_file($from, $to) ){
        echo 'Success';   
    } else {
        echo 'Failure';   
    }

    header('Location: http://www.mywebsite.com/dump/');
    exit;
}
?>
0
2019-05-17 01:29:07
Source

Warning : move_uploaded_file () [function.move - uploaded - file ] : Unable to relocate 'C :\ WINDOWS \ Temp \ phpA30E.tmp' to './ people.xml' in E :\ inetpub \ vhosts \ mywebsite.com \ httpdocs \ dump \ upload.php on line 3

is the vital line it claims you can not place the file where you desire it and also this generally suggests an approvals trouble

examine the procedure running the application (generally the webservers procedure for php) has the civil liberties to write a file there.

EDIT :

hold on a little bit I beat the gun a little is the path to the file in the first line deal with?

0
2019-05-10 05:45:39
Source

As it's Windows, there is no actual 777. If you're making use of chmod, examine the Windows - relevant remarks.

Examine that the IIS Account can accessibility (read, write, change) these 2 folders :

E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\
C:\WINDOWS\Temp\
0
2019-05-10 05:45:09
Source