我试图建立一个允许用户添加个人资料图片的网站。因此,我有这个upload.php:
JLabel obj = (JLabel) me.getSource();
System.out.println(obj.getText());
我需要在home.php中使用$ fileActualExt。这是代码:
<?php
if (!isset($_SESSION)) {
session_start();}
include_once 'includes/dbh.inc.php';
$id = $_SESSION['key'];
if (isset($_POST['submitFile'])) {
$file = $_FILES['file'];
$fileName = $file['name'];
$fileTmpName = $file['tmp_name'];
$fileSize = $file['size'];
$fileError = $file['error'];
$fileType = $file['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg', 'jpeg', 'png');
if (in_array($fileActualExt, $allowed)) {
if ($fileError == 0) {
if ($fileSize < 1000000) {
$fileNameNew = "profile".$id.".".$fileActualExt;
$fileDestination = 'uploads/'.$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);
$sql = "UPDATE profileimg SET status=0 WHERE userid='$id';";
$resultImg = mysqli_query($conn, $sql);
header("Location: home.php?upload=success");
}
else { echo "Sorry, your file size is too big.";}
}
else { echo "Oops, an error occurred!";}
}
else { echo "Please upload png and jpg files only.";}
}
我需要在upload.php中的文件扩展名插入我home.php中的img src。
在home.php的顶部,我有session_start()并包含&#39; upload.php&#39;
当我加载我的网站时,它显示了个人资料图片,我认为它不会。 有一个错误表示&#34;未定义的变量:fileActualExt&#34;