Php 如何在本地服务器上上载图像
经过80多次(使用本站所有提示也)没有结果。(我在Debian服务器和windows 10上工作) 我是在互联网上做的,但不是在本地服务器上 我的代码如下:Php 如何在本地服务器上上载图像,php,Php,经过80多次(使用本站所有提示也)没有结果。(我在Debian服务器和windows 10上工作) 我是在互联网上做的,但不是在本地服务器上 我的代码如下: <html> <head> <meta charset="utf-8"> </head> <body> <form action="upload_OneImage.php" method="post" enctype="multipart/form-d
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form action="upload_OneImage.php" method="post" enctype="multipart/form-data">
<input type="file" name="photoU" /><br />
<input type="submit" name="submit" value="Upload" />
</form>
<?php
$valid_file = NULL;
if (isset($_POST['submit'])) {
//if they DID upload a file...
if ($_FILES['photoU']['name']) {
//if no errors...
if (!$_FILES['photoU']['error']) {
//check the size of file and validate it's size
$new_file_name = strtolower($_FILES['photoU']['name']);
//change the all the capital letter to lower letter
echo "file_name= $new_file_name <br />";
if ($_FILES['photoU']['size'] > (1024000)) { //can't be larger than 1 MB
$valid_file = FALSE;
$message = "Oops! Your file's size is too large.";
} else {
$valid_file = TRUE;
}
//if the test was successfull
if ($valid_file) {
//move it to directory that name "upload"
move_uploaded_file($_FILES["file"]["tmp_name"][0], "upload/" . $_FILES["file"]["name"][0]);
//move_uploaded_file($_FILES['photoU']['tmp_name'], 'upload/' . $new_file_name);
$message = 'Congratulations! Your file was accepted.<br />';
}
}
//if there is an error...
else {
//set that to be the returned message
$message = 'Sorry! Your upload triggered the following error: ' . $_FILES['photoU']['error'];
}
}
echo "$message ";
}
?>
</body>
</html>
你应该告诉我们问题出在哪里。然后我们可以帮你解决这个问题。如果你不知道问题出在哪里,你需要调试你的代码:检查每一行代码,检查你调用的函数返回的每一个值,检查你的If
块中运行了哪些代码行。你应该告诉我们问题出在哪里。然后我们可以帮你解决这个问题。如果不知道问题出在哪里,则需要调试代码:检查每一行代码,检查调用的函数返回的每一个值,检查If
块中运行的代码行。