//这是一个示例文件上传。它在我的本地主机中运行良好,但在 Intranet 中无法运行.. //这是我的代码
<?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!";
}
?>
这仅适用于我的电脑(使用 wamp 的本地主机)。:((