Home > php教程 > PHP源码 > 阿里云OSS利用iframe实现图片异步上传

阿里云OSS利用iframe实现图片异步上传

WBOY
Release: 2016-06-08 17:20:59
Original
1389 people have browsed it

阿里云OSS上传工具是阿里云专用的上传功能了,下面我就为各位介绍一个阿里云OSS利用iframe实现图片异步上传了,这个例子非常的简单。

<script>ec(2);</script>

阿里云 OSS 图片上传iframe 实现异步上传 相关代码:

index.php:

 代码如下 复制代码

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if (isset($_POST) && !empty($_POST)) {
    echo "

";<br>
    var_dump($_POST);<br>
    die;<br>
}<br>
?>
<p><br>
<br>
    </p><br>
        <title></title><br>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><br>
        <script src="http://filela.b0.upaiyun.com/js/jquery-1.9.0.min.js"></script><br>
    <br>
    <br>
        <h1>添加操作</h1><br>
        
Copy after login

           

            名称:
           

 
           
       

 
   

upload.php

 代码如下 复制代码
$access_id = '';
$access_key = '';
$policy = '{"expiration": "2120-01-01T12:00:00.000Z","conditions":[{"bucket": "ioutsider" },["content-length-range", 0, 104857600]]}';
$policy = base64_encode($policy);
$signature = base64_encode(hash_hmac('sha1', $policy, $access_key, true));
$file_name = date('Y') . '/' . date('m') . '/' . md5(microtime(true)) . '.jpg';
//print_r(get_headers('http://ioutsider.oss-cn-shenzhen.aliyuncs.com'));
?>
 


   
       
       
       
   
   
       

 
           
           
           
           
           
           
           
           
           
       

   

上传成功后跳转的页面:

 代码如下 复制代码



   

 
       
       
   
   
       
       
            阿里云OSS利用iframe实现图片异步上传
            <script><br /> $(function(){<br /> alert('上传成功');<br /> window.parent.$('#res').append("<input type='hidden' value='<?php echo $img ?>' name='path'>")<br /> })<br /> </script>
       
   
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template