Uploadify realize seven cow cloud storage display upload Progress + page display

Source: Internet
Author: User

Get ready:

Uploadify:

http://www.uploadify.com/download/

Seven Bull PHP-SDK Development Guide:

Http://developer.qiniu.com/docs/v6/sdk/php-sdk.html

PHP-SDK Address:

Https://github.com/qiniu/php-sdk

Begin:

DEMO:

http://hxend.com/uploadif/

Become a standard user after registering an account with seven cows

Free storage space 10GB
Free monthly Download Traffic 10GB
Free Put/delete 100,000 requests per month
Free monthly get 1 million requests

It seems to be a good benefit.

After successful registration, the Account page has AK and SK key can be used in the code.

Download good uploadify and put the contents of the seven-ox PHP-SDK package inside the uploadify.

Open the uploadify.php file code as follows:

<?php/*uploadifycopyright (c) reactive Apps, Ronnie garciareleased under the MIT License <HTTP://WWW.OPENSOURC E.org/licenses/mit-license.php> *///Define a destination$targetfolder = '/uploads '; Relative to the Root$verifytoken = MD5 (' Unique_salt '. $_post[' timestamp '); if (!empty ($_files) && $_post[' Tok En '] = = $verifyToken) {$tempFile = $_files[' Filedata ' [' tmp_name ']; $targetPath = $_server[' Document_root ']. $ TargetFolder; $targetFile = RTrim ($targetPath, '/'). ‘/‘ . $_files[' Filedata ' [' Name '];//Validate the file Type$filetypes = array (' jpg ', ' jpeg ', ' gif ', ' PNG '); File extensions$fileparts = pathinfo ($_files[' Filedata ' [' name ']); if (In_array ($fileParts [' extension '],$ FileTypes) {move_uploaded_file ($tempFile, $targetFile); Echo ' 1 ';} else {echo ' Invalid file type. ';}}? >

Modify the code as follows: introduce the reference code inside.

<?php$verifytoken = MD5 (' Unique_salt '. $_post[' timestamp '); if (!empty ($_files) && $_post[' token '] = = $    Verifytoken) {$tempFile = $_files[' Filedata '] [' tmp_name ']; Generate a new file name $filename = Time (). Mt_rand (10,99). End (Explode ('. ', $_files[' Filedata ' [' name ']));  Here to modify the birth of a random image name $fileTypes = array (' jpg ', ' jpeg ', ' gif ', ' PNG ');    Restrict uploaded files to picture $fileParts = PathInfo ($_files[' Filedata ' [' name ']);        if (In_array ($fileParts [' extension '], $fileTypes)) {//upload image to cloud start require_once ("qiniu/io.php");        Require_once ("qiniu/rs.php");        $bucket = "hdimg";//Space name//intercept original file suffix name $key 1 = "uploads/". $filename; $accessKey = "; Here to fill ak $secretKey = ';        Here fill in SK Qiniu_setkeys ($accessKey, $secretKey);        $putPolicy = new Qiniu_rs_putpolicy ($bucket);        $upToken = $putPolicy->token (null);        $putExtra = new Qiniu_putextra ();        $putExtra-&GT;CRC32 = 1; $tempFile uploadify uploaded temporary file path list ($ret, $erR) = Qiniu_putfile ($upToken, $key 1, $tempFile, $putExtra); Upload image to cloud end//return file name to the front desk echo "http://hdimg.qiniudn.com/". $key 1;    The foreground uses the data parameter of the callback function to receive} else {echo ' Invalid file type. '; }}

Foreground index.php modified to: The foreground invokes the value of ECHO output data for operation.

<! DOCTYPE html>

The data is entered into the page to implement the current page display. The value of the control #txtimg is the data value of the output as the picture address.

Later, if you need an IFRAME call, you can put

document.getElementById (' txtimg '). Src=data;  Data can be transferred to the #txtimg of the parent page.
Parent.document.getElementById (' txtimg '). Src=data;

DEMO:

http://hxend.com/uploadif/

Bowen to Stone and blog Park All, reproduced please indicate the source, convenient update.
Http://www.cnblogs.com/webers/p/4162108.html

Uploadify implementation Seven Cow cloud storage display upload progress + page display

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.