zimg

jQuery加PHP实现图片上传并提交

巧了我就是萌 提交于 2020-08-11 20:52:05
图片上传思路:通过ajax实现图片上传,然后把PHP返回的图片地址,加入到隐藏字段中,最后通过表单提交给后台PHP,代码如下 HTML代码 zimg.html文件: <! DOCTYPE html > < html lang ="en" > < head > < meta charset ="UTF-8" > < meta name ="viewport" content ="width=device-width, initial-scale=1.0" > < title > 自定义上传图片 </ title > </ head > < body > < form action ="a.php?action=2" method ="post" > < span > 上传图片 </ span > < span > < input type ="file" id ="img_url" name ="img_url" accept =".jpg, .gif, .jpeg, .bmp, .png" /> < a onclick ="UpLoadImg()" > 上传 </ a > < input type ="hidden" id ="url_data" name ="url_data" /> </ span > < br > < span > < input type ="submit"