仅发布图像文件或允许不发布任何文件
Post only an image file OR allow post of no file
如果
应该发布的文件不是图像,JavaScript中是否有办法发布警报,或者如果没有选择文件,则返回true?
以下工作正常。在表单上提交 php 代码
<?php
$fileType = $_FILES['avatarfile']['type'];
if(isset($_POST['submit']) && (($_FILES['avatarfile']['type'] == "image/gif")
|| ($_FILES['avatarfile']['type'] == "image/jpeg")
|| ($_FILES['avatarfile']['type'] == "image/pjpeg") || ($_FILES['avatarfile']['type'] == "image/bmp") || ($_FILES['avatarfile']['type'] == "image/png") || $fileType == NULL))
{
$query="insert into ...)";
header('Location:something.php');
}
else {
echo "The file you tried to upload is not an image";
}
?>
相关文章:
- 使用本地文件而不是$.getJSON
- grunt上的压缩文件夹不起作用
- 如何使用JavaScript粘贴原始二进制文件而不出现“无效字符”错误
- jQueryAjax调用在单独的.js文件中不起作用
- google.setOnLoadCallback()在单独的JS文件中不起作用
- 输入类型=“;文件“;onclick有效,但文件选择不显示
- 如何提供保存文件而不是从internet explorer打印文件的选项
- 日食添加文件而不将其复制到工作区中
- Onedrive api 如何附加文件而不是下载
- 通过 Dropbox API 上传时的文件内容不一致
- 当我在操作属性中写入页面名称时,文件图像不会上传
- ng-class 在 angularJs 中由 ng-include 包含的文件内不起作用
- JavaScript在嵌入SVG文件中不起作用
- Javascript函数在jsp文件中不起作用
- 如何使用Chrome文档中的文件而不是URL
- jQuery($)在模块文件中不可用
- Dojo Build-copyOnly在概要文件中不起作用
- 调试器关键字在Visual Studio的javascript文件中不起作用
- jQuery/JavaScript代码如何将表导出为CSV文件而不考虑表's大小.看看@jsfiddle链接
- 从js文件而不是xml文件创建关联数组