使用我的PHP代码时出现此错误
PHP语法检查:解析错误:语法错误,第7行代码中的意外'}'
请帮助我,我不明白我在这里做错了什么 php代码:
<?php
if ( $ready == "false" ) {
$rand = chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122));
$folder = "uploads/".$rand
}
if ( !is_dir($folder) ) {
$ready = "true"
}
if ( is_dir($folder) ) {
$ready = "false"
}
if ( $ready == "true" ) {
$that = "yes"
mkdir("uploads/".$rand);
$to = "Uploads/".$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], $to);
echo "uploaded";
}
?>
<form method="post" enctype="multipart/form-data">
<label>Choose a file:</label>
<input type="hidden" name="upload" value="1">
<input type="file" name="file">
<input type="submit" value="upload" onclick="$other = "yes""/>
</form>
答案 0 :(得分:2)
您在许多行完整代码中错过了;
:
if ( $ready == "false" ) {
$rand = chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122));
$folder = "uploads/".$rand ;
}
if ( !is_dir($folder) ) {
$ready = "true";
}
if ( is_dir($folder) ) {
$ready = "false";
}
if ( $ready == "true" ) {
$that = "yes";
mkdir("uploads/".$rand);
$to = "uploads/".$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], $to);
echo "uploaded";
}
答案 1 :(得分:1)
你忘记了第7行末尾的分号。语句不完整,因此解析器不会指望大括号。
if ( $ready == "false" ) {
$rand = chr(rand(97, 122)). chr(rand(97, 122)). chr(rand(97, 122));
$folder = "uploads/".$rand ;
}