sae-uploading local images to SAE's storage (PHP version)

Source: Internet
Author: User

Sina's SAE is in a secure period and does not support the SAE that uploads local files directly.


That is, you cannot select files by selecting the File button, after clicking Submit, the file cannot be successfully submitted to the SAE cloud server. need to passSAEprovided byStorageto achieve, throughSotrageof theAPIinterface to upload a local file.SAEof theStorage, and then by accessingStoragein the file to achieve this effect!!


The following is a step through the picture to explain:

1. Open our SAE application in service management here you can see storage


2. Then click Storage to go in and see the following screen

3. Click on the new domain name to start, this domain is used to store the future of our uploaded files, create a good after you can click on domain management to view our created domain

4. All have, now only owe us by writing procedures to this domain storage data, I use PHP language, other language principle is the same!

<?php//When the user clicks submit submission to upload the file if (Isset ($_post["Submit")) {//Create SAE Storage storage $storage= new Saestorage ();//Create SAE Storage Storage Object $domain = ' Kepuna ';//Here The $domain corresponds to the name of its own name $filetype = $_files["File" ["type"]; The type of file being uploaded if ($fileType = = "Image/gif") | | ($fileType = = "Image/jpeg") | | ($fileType = = "Image/jpg") | | ($fileType = = "Image/png")) {if ($storage->fileexists ($domain, $filename) = = True) {//Determine if the file already exists echo "<p style= ' background: #FCC9C4; border -radius:0.3em;padding:5px;color: #fff; "        > image already exists, please re-upload!</p> ";         }else{$filename = $_files["File" ["name"]; $storage->upload ($domain, $filename, $_files[file][tmp_name]); echo "<p style= ' background: #7CBD55; Border-radius:0.3em;padding:5px;color: #fff; ' > Image upload Success!        </p> ";           echo "<script> window.location= ' showimage.php ';</script>"; <span style= "White-space:pre" &GT;&LT;/SPAN&GT;}}else{echo "<p style=" background: #FCC9C4; border-radius:0.3em ;p adding:5px;color: #fff; " > The number of pictures is not correct, upload failed! &lT;/p> "; }}?><! DOCTYPE html>

Look under: A little card everyone can put code to test their own machine on the run under



How do we access this through the program we store inDomainin the picture that?

Next up is showimage.php's content.

<?php$sae_storage = new Saestorage (); $domainName = "Kepuna"; $listArray = $sae _storage->getlist ($domainName);        foreach ($listArray as $image) {    echo "


There are many ways, I'm just one of them, and I can refer to

Http://apidoc.sinaapp.com/class-SaeStorage.html This SAE official document for everyone to explore, very simple!

Here are all the pictures in my domain

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

sae-uploading local images to SAE's storage (PHP version)

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.