我在注册部分的内容管理系统中这样做。我想添加配置文件图像,我不喜欢w3学校啧啧:https://www.w3schools.com/php/php_file_upload.asp.我做它ant=其他文件它可以,但当我在我的文件中运行我得到一个错误:警告:未定义的数组键"profileimg_regis"在C:\xampp\htdocs\DeKnoinarakDev\dashboard\在99号线code.php
警告:试图访问C:\xampp\htdocs\deknoarkdev\dashboard\run\code中null类型值的数组偏移量。php在线99
警告:第103行C:\xampp\htdocs\DeKnoinarakDev\dashboard\run\code.php中未定义的数组键“profileimg_regis”
警告:试图在第103行的C:\xampp\htdocs\DeKnoinarakDev\dashboard\run\code.php中访问类型null值的数组偏移
致命错误:未捕获的值错误:路径不能为空在C:\xampp\htdocs\DeKnoinarakDev\dashboard\run\code.php:103堆栈跟踪:#0 C:\xampp\htdocs\DeKnoinarakDev\dashboard\run\code.php(103): getimagesize(")#1{main}抛出在C:\xampp\HTDocs\DeKnoinarakDev\dashboard\run\code.phpon line 103
这是我的PHP代码:
// Check if image file is a actual image or fake image
if(isset($_POST["register_btn"])) {
$target_dir = "img/user/";
$target_file = $target_dir . basename($_FILES["profileimg_regis"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
$check = getimagesize($_FILES["profileimg_regis"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
}
else {
echo "File is not an image.";
$uploadOk = 0;
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["profileimg_regis"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") {
echo "Sorry, only JPG, JPEG & PNG files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
}
else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
这是我的HTML代码:
<div class="modal-background" id="md-regisadmin">
<div class="modal-container">
<div class="modal">
<div class="modal-header">
<h2>Admin Account</h2>
<button onclick="closeModal(document.querySelectorAll('#md-regisadmin'))" type="button" id="dismiss-btn-modal">
<i class="fa fa-times" onclick="closeModal(document.querySelectorAll('#md-regisadmin'))" id="dismiss-btn-modal"></i>
</button>
</div>
<div class="md-content">
<div class="form-modal">
<div class="form-group md">
<form action="run/code.php" method="post">
<!--<label for="username_regis">Username:</label>
<input id="username_regis" type="text" name="username_regis" placeholder="Username" required/>
</div>
<div class="form-group md">
<label for="email_regis">E-mail:</label>
<input id="email_regis" type="email" name="email_regis" placeholder="Email" required/>
</div>
<div class="form-group md">
<label for="pwd_regis">Password:</label>
<input id="pwd_regis" type="password" name="pwd_regis" placeholder="Password" required/>
</div>
<div class="form-group md">
<label for="pwdr_regis">Repeat Password:</label>
<input id="pwdr_regis" type="password" name="pwdr_regis" placeholder="Repeat Password" required/>
</div>
<div class="form-group md">-->
<input id="profileimg_regis" name="profileimg_regis" type="file"/>
<!--</div>
<div class="form-group md">
<label for="utype_regis">Usertype:</label>
<select id="utype_regis" name="utype_regis"/>
<option value="noper">No Permission</option>
<option value="readonly">Reader</option>
<option value="mod">Moderator (Only Change Data In Website)</option>
<option value="admin">Administrator</option>
<option value="superadmin">Super Administrator</option>
<option value="godper">God Permission</option>
<option value="root">Root Administrator</option>
</select>
</div>
</div>
</div>-->
<div class="modal-footer">
<button type="submit" name="register_btn">
Add Admin Account
</button>
</form>
<button type="button" onclick="closeModal(document.querySelectorAll('#md-regisadmin'))" id="dismiss3-btn-modal">
<a onclick="closeModal(document.querySelectorAll('#md-regisadmin'))" id="dismiss2-btn-modal">Cancel</a>
</button>
</div>
</div>
</div>
</div>
如果你能帮忙,谢谢你。:)
现在我找到了修复它的方法。我忘了
我必须将我的网站更新到PHP7.4的最后一个版本,之后我在一些插件中发现了这个通知 **>注意:试图访问中类型为null的值的数组偏移量 add var_dump($args)后的结果;在@Ro Achterberg建议的foreach之前 数组(2){[0]=>数组(3){[0]=>NULL[1]=>数组(2){[0]=>string(3)“var”[1]=>string(23)“ekit-me
我刚刚将服务器的PHP版本升级到PHP 7.4.1,现在出现以下错误: 注意:尝试访问中bool类型值的数组偏移量 PHP7.4的修复程序是什么?
问题内容: 我有一个类Hra1,它定义了游戏规则(game = hra)。问题是,尽管在构造函数中创建了poleMinci数组,但我得到的是空值,例如poleMinci == null。换句话说,玩家的move方法始终返回false。 构造函数: 球员的移动方法: 问题答案: 您正在阴影变量: 在该构造函数中,由于poleMinci是在构造函数内部声明的,因此仅在构造函数内部可见。如果您在类中具有
问题内容: 我在PHP中收到以下错误 注意未定义的偏移量1:在C:\ wamp \ www \ includes \ imdbgrabber.php第36行中 这是导致它的PHP代码: 错误是什么意思? 问题答案: 如果找不到匹配项,则为空数组。因此,您应该在访问之前检查是否找到了匹配项,例如:
TypeError:单例数组( 当我试图在我的自定义AZHU_EmailClassifier_2类中运行train_test_split函数时,我遇到了这个错误。 我的班级: 当我运行train_test_split函数时,会触发错误。 整个错误消息: -------------------------------------------------------------------------