php 文件限制,PHP文件类型限制

我正在尝试PHP我的第一个实际脚本,大部分来自教程:(

无论如何

这个部分我有问题

// This is our limit file type condition

if (!($uploaded_type=="text/java")||!($uploaded_type=="file/class")||!($uploaded_type=="file/jar")) {

echo "You may only upload Java files.
";

$ok=0;

}基本上它不允许任何文件,即使那些文件

帮帮我!

我只想让Java文件被允许!

编辑:

这是完整的代码

$target = "upload/";

$target = $target . basename( $_FILES['uploaded']['name']) ;

$uploaded = basename( $_FILES['uploaded']['name']) ;

$ok=1;

//This is our size condition

if ($uploaded_size > 350000) {

echo "Your file is too large.
";

$ok=0;

}

// This is our limit file type condition

if (!($uploaded_type=="text/java")||!($uploaded_type=="file/class")||! ($uploaded_type=="file/jar")) {

echo "You may only upload Java files.
";

$ok=0;

}

echo $ok; //Here we check that $ok was not set to 0 by an error

if ($ok==0) {

echo "Sorry your file was not uploaded";

}else {

if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {

echo "The file ". $uploaded ." has been uploaded";

} else {

echo "Sorry, there was a problem uploading your file.";

}

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值