Javascript-iframe Upload image return address

Source: Internet
Author: User
Keywords Javascript php html5

I'm going to put together an IMG tag after uploading the image, and then write the tag to the ID of the parent page for the photo content.

This is the parent page:

PHP after the successful upload code:

           if(move_uploaded_file($tmp, $path.$dir.$image_name)){                $src = "";                //$src = 1;                echo "";            }else{                echo <<
  
   < code="">

浏览器报错如下:Uncaught SyntaxError: Unexpected token ILLEGAL

Reply content:

I'm going to put together an IMG tag after uploading the image, and then write the tag to the ID of the parent page for the photo content.

This is the parent page:

PHP after the successful upload code:

           if(move_uploaded_file($tmp, $path.$dir.$image_name)){                $src = "";                //$src = 1;                echo "";            }else{                echo <<
  
    < code="">

浏览器报错如下:Uncaught SyntaxError: Unexpected token ILLEGAL

非常不建议把php代码与js代码柔和在一起啊,很难理解。而且容易出错。分离分离分离。

没怎么用过php,看看是不是字符串连接的方式错了?php好像是用.来连接吧?

路径中的 \ 要转义

建议楼主学会拆分问题,你所说的问题可以拆分成两个单例:
1- iframe中执行js向父窗口传递信息
2- 图片上传处理
这样你能更准确的发现到底哪里出了问题。
对于1来说,可以这样测试

//a.html//b.html

对于2也是一样,不需要调用js,上传成功后直接echo '';

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.