if(isset($_FILES['school_logo']['name']) && $_FILES['school_logo']['name'] != "") {
if( ($_FILES['school_logo']["type"] == "image/pjpeg") ||
($_FILES['school_logo']["type"] == "image/jpeg") ||
($_FILES['school_logo']["type"] == "image/gif") ||
($_FILES['school_logo']["type"] == "image/png")) {
$db_coulm_val = "";
$directory = "../uploads/schools_logos/";
$logo_name = $_FILES['school_logo']['name'];
$twmporayr_logo_name = $_FILES['school_logo']['tmp_name'];
$complete_directory_name = $directory.time().$_FILES['school_logo']['name'];
if(move_uploaded_file($twmporayr_logo_name, $complete_directory_name)) {
$db_coulm_val = " s_logo = '".$logo_name."', ";
} else {
echo "ERROR Uploading Logo....";
}
}
else
{
echo "<h2 style='color:red; text-align:center;'>Sorry Only Jpg, Png and Gif Formats are Allowed For Images.</h2>";
die();
}
}
这是用户上传图片的表单的一部分。我无法上传图片。 SQL确实保留了文件名。只允许指定的文件扩展名时,它正确地给我一个错误。如果有错误,它不会回显ERROR Uploading Logo ....除了上传图片的实际部分外,似乎一切正常。
有什么建议吗?
答案 0 :(得分:-1)
这是正确图像上传文件的工作示例。起初我没有理解你的例子。我现在编辑了添加适当的变量。
以下是代码:
{'album_artist': 'Coleman Hawkins with Eddie “Lockjaw” Davis', 'artist': 'Coleman Hawkins with Eddie “Lockjaw” Davis', 'album': 'Ñíght Håwk 你好', 'bitrate': 744}
path=/tmp/foo.txt
{'album_artist': 'Coleman Hawkins with Eddie “Lockjaw” Davis', 'artist': 'Coleman Hawkins with Eddie “Lockjaw” Davis', 'album': 'Ñíght Håwk 你好', 'bitrate': 744}