脚本宝典收集整理的这篇文章主要介绍了php不接受所有图片扩展名?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
function change_PRofile_image($user_id,$file_temp,$file_extn) { $file_path = 'profile/' . substr (md5(time()),10) . '.' . $file_extn; move_uploaded_file($file_temp,$file_path); MysqL_query("UPDATE `users` SET `profile` = " . MysqL_real_escape_string($file_path) . "' WHERE `user_id` = " . (int)$user_id); } if (isset($_FILES['profile']) === true) { if (empty($_FILES['profile']['name']) === true) { echo 'y u no choose file!'; } else { $Allowed = array ('jpg','jpeg','gif','png'); //this is the part i think may be brocken. $file_name = $_FILES['profile']['name']; $file_extn = strtolower(end(explode (' . ',$file_name))); $file_temp = $_FILES['profile']['tmp_name']; if (in_array($file_extn,$allowed) === true) { change_profile_image($session_user_id,$file_extn); header('Location: dontdelete.PHP'); exIT(); }else { echo 'y u no jpg or png or gif'; } } } if (empty($user_data['profile']) === false) { echo '<img src"',$user_data['profile'],'" alt="">'; }
您还需要检查其有效图像,而不仅仅是以图像扩展名结尾.
你的img输出中你也缺少了=你也可以连续3次而不是回声:
echo’< img src =“'.$user_data ['profile'].'”alt =“”>‘;
以上是脚本宝典为你收集整理的php不接受所有图片扩展名?全部内容,希望文章能够帮你解决php不接受所有图片扩展名?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。