微信iframe

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:18:46
Original
1673 people have browsed it

  1. 微信公众平台开发,表单要上传图片。思路见代码

  2. html部分

    <code>   <form id="form_file" method="post" action="upload.php" target="frameFile" enctype="multipart/form-data">
        <img  id="pre-img" src="" alt="微信iframe" >
        <input type="file" name="image_url" id="file_upload" value="上传图片">
        <input type="hidden" name="img" value="">
       </form></code>
    Copy after login
    Copy after login

    js部分

    <code>   $(function(){
       $('#file_upload').change(function(){
           $('#form_file').submit();
       });
       });
       function upload_success (msg) {
       if (msg.err == 0) {
           $('#pre-img').attr('src',  msg.file_path);
           $('input[name="img"]').val(msg.file_path);
       } else {
           swal(msg.msg);
           return false;
       }
       }</code>
    Copy after login
    Copy after login

    PHP处理

<code>//  图片上传错误处理
if ($img_info['error']) {
    $response = array('err'=>1, 'msg'=>$img_info['error']);
} else {
    $response = array(
        'err'=>0,
        'file_path'=>$img_info['image_url']['savepath'].$img_info['image_url']['savename']
    );
}
</code>
Copy after login
Copy after login
  1. 电脑上测试是正常,但是传到微信上就会post到新的空白页。

求解!

回复内容:

  1. 微信公众平台开发,表单要上传图片。思路见代码

  2. html部分

    <code>   <form id="form_file" method="post" action="upload.php" target="frameFile" enctype="multipart/form-data">
        <img  id="pre-img" src="" alt="微信iframe" >
        <input type="file" name="image_url" id="file_upload" value="上传图片">
        <input type="hidden" name="img" value="">
       </form></code>
    Copy after login
    Copy after login

    js部分

    <code>   $(function(){
       $('#file_upload').change(function(){
           $('#form_file').submit();
       });
       });
       function upload_success (msg) {
       if (msg.err == 0) {
           $('#pre-img').attr('src',  msg.file_path);
           $('input[name="img"]').val(msg.file_path);
       } else {
           swal(msg.msg);
           return false;
       }
       }</code>
    Copy after login
    Copy after login

    PHP处理

<code>//  图片上传错误处理
if ($img_info['error']) {
    $response = array('err'=>1, 'msg'=>$img_info['error']);
} else {
    $response = array(
        'err'=>0,
        'file_path'=>$img_info['image_url']['savepath'].$img_info['image_url']['savename']
    );
}
</code>
Copy after login
Copy after login
  1. 电脑上测试是正常,但是传到微信上就会post到新的空白页。

求解!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template