0

//これはサンプル ファイルのアップロードです。私のローカルホストでは問題なく動作しますが、イントラネットでは動作しませんでした.. //これは私のコードです

<?php require_once "../session.php" ?>
<?php
$host='localhost'; // My hostname
$username='root'; // Mysql username
$password='*******'; // Mysql password
$db_name='jobs'; // DB name

// Connect to server and select database.
mysql_connect($host, $username, $password)or die("Cannot Connect");
mysql_select_db($db_name);

// Where the file is going to be placed 
$TARGET_PATH = "uploads/";
// Get our POSTed variables
$uploadedfile = $_FILES['uploadedfile'];
// Sanitize our inputs
$uploadedfile['name'] = mysql_real_escape_string($uploadedfile['name']);

// Build our target path full string.  This is where the file will be moved do
// i.e.  images/picture.jpg
$TARGET_PATH .= $uploadedfile['name'];

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if (move_uploaded_file($uploadedfile['tmp_name'], $TARGET_PATH))
{
    $sql = "update personal set resume='" . $uploadedfile['name'] . "' where username='".$_SESSION['name']."'";
    $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
    header("Location: ../scripts/view.php");
    exit;
}
else
    {
        echo "There was an error uploading the file, please try again!";
    }

?>

これは私のPC(wampを使用するlocalhost)でのみ機能します。:(((

4

2 に答える 2

0

uploads/フォルダに対する適切な権限があることを確認してください。Filezilla を使用して構成します。

于 2012-08-02T03:32:57.973 に答える
0

サーバーが正常に動作していることを確認しましたが、アップロード ディレクトリの権限に問題があるか、アップロード ディレクトリのパスが間違っている可能性があります。

<html>
<body>

<form action="fileupload.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="uploadedfile" id="uploadedfile" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html> 

//あなたのphpコード

<?php require_once "../session.php" ?>
<?php
$host='localhost'; // My hostname
$username='root'; // Mysql username
$password=''; // Mysql password
$db_name='blog'; // DB name

// Connect to server and select database.
mysql_connect($host, $username, $password)or die("Cannot Connect");
mysql_select_db($db_name);

// Where the file is going to be placed 
$TARGET_PATH = "uploads/";
// Get our POSTed variables
$uploadedfile = $_FILES['uploadedfile'];
// Sanitize our inputs
$uploadedfile['name'] = mysql_real_escape_string($uploadedfile['name']);

// Build our target path full string.  This is where the file will be moved do
// i.e.  images/picture.jpg
$TARGET_PATH .= $uploadedfile['name'];

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if (move_uploaded_file($uploadedfile['tmp_name'], $TARGET_PATH))
{
    echo $sql = "update personal set resume='" . $uploadedfile['name'] . "' where username='".$_SESSION['name']."'";
    $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error());
    header("Location: ../scripts/view.php");
    exit;
}
else
    {
        echo "There was an error uploading the file, please try again!";
    }

?>
于 2012-08-02T03:39:00.093 に答える