SAE-Upload local images to the Storagephp version of SAE
Sina’s SAE is in a security period and does not support SAE that directly uploads local files.
That is, I cannot select a local file through the Select File button. After clicking Submit, the file cannot be successfully submitted to the SAE cloud server. What should I do? ?
The following is a step-by-step explanation through pictures:
1. Open our SAE application and you can see storage in the service management here
2. Then click storage to enter and you will see the following interface
3. Click to create a new domain with a random name. This domain will be used to store the files we upload in the future. After creating it, you can click domain management to view what we have created. The domain
4. Everything is ready. Now we just need to write a program to store data in this domain. I use PHP language, and the principle is the same for other languages!
<?php // 当用户点击submit提交上传的文件时 if(isset($_POST["submit"])){ // 创建SAE storage存储 $storage= new SaeStorage();// 创建SAE storage存储对象 $domain = 'kepuna';// 这里的$domain对应得名字就是自己起的名字 $fileType = $_FILES["file"]["type"]; //被上传文件的类型 if(($fileType=="image/gif") || ($fileType=="image/jpeg")||($fileType=="image/jpg")||($fileType=="image/png")){ if($storage->fileExists($domain,$filename) == true) {// 判断文件是否已经存在 echo "<p style='background:#FCC9C4;border-radius: 0.3em;padding:5px;color:#fff;''>图片已存在,请重新上传!</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;'>图片上传成功!</p>"; echo "<script> window.location='showImage.php';</script>"; <span style="white-space:pre"> </span>} }else{ echo "<p style='background:#FCC9C4;border-radius: 0.3em;padding:5px;color:#fff;''>图片格数不正确,上传失败!</p>"; } } ?> <!DOCTYPE HTML> <html> <head> <title></title> <meta charset="utf-8" /> <meta name="viewport" c <link href="./css/style.css" rel="stylesheet" type="text/css" media="all" /> </head> <body> <form method="POST" enctype="multipart/form-data" class="uploadImageForm"> <input type="file" name="file" id="file" /> <input type="submit" value="Submit" name="submit"/> </form> </body> </html>
Look at the renderings: if there is a bit of a lag, you can try the code and run it on your own machine
The next is the content of showImage.php
<?php $sae_storage = new SaeStorage(); $domainName = "kepuna"; $listArray = $sae_storage->getList($domainName); foreach($listArray as $image){ echo "<img src='http://hjmshop-kepuna.stor.sinaapp.com/$image'/>"; } ?>
http: //apidoc.sinaapp.com/class-SaeStorage.html You can explore this SAE official document yourself, it’s very simple!
The following are all the pictures in my domain
Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces SAE-upload local images to the Storagephp version of SAE, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
