Storage Service usage for SAE

Source: Internet
Author: User
Tags mkdir

Today I finally figured out how to use SAE's storage.

Because the SAE does not support file permission settings, all code files are not counted. However, the SAE provides a particularly good distributed file storage service to store persistent files. In fact, is used to store the site's material files, such as pictures, documents and so on.

So, when you need to store the file data, you can use the SAE.

There are altogether two options for using the SAE.

One of the official programmes offered was:

Using the official storage class, you can directly perform file operations, such as storing files, deleting files, modifying files, and so on.

Another way I see it in the SAE App Store is a synthetic WordPress for SAE.

We can see the detailed code, I now put my own simple test code to the following: (only to implement storage, not for development scenarios)

  code is as follows &nbs P;
<HTML>
<body>
 
<form action= "" Method = "POST" enctype= "Multipart/form-data"
<label for= "file" >FILENAME:</LABEL>
<input type= " File "name=" file "id=" file "/> 
<br/>
<input type=" Submit "name=" submit "value=" Submit "/>< br> </form>
 
</body>
 
<?php
 
$domain = "Test" ;
$upload _dir = "saestor://". $domain. "/QIAO1/2/3/4/5/";
 
if (!is_dir ($upload _dir))
{
 //mkdir ($upload _dir, 0777);
}
 
if ($_files["file" ["error"] > 0)
  {
  echo "error:". $_files["File" ["Error"]. "<br/>";
 }
Else
  {
  echo "Upload:". $_files["File" ["Name"]. "<br/> ";
  echo "Type:". $_files["File" ["type"]. "<br/>";
  echo "Size:". ($_files["File"] ["size"]/1024). "Kb<br/>";
  echo "Stored in:". $_files["File" ["Tmp_name"];
 
 }
if (move_uploaded_file $_files["file" ["Tmp_name"], $upload _dir. $_files["File" [' Name '] )
{
 echo ' OK ';
}
 
 
//mkdir ($upload _dir. ' Qiao ', 0777);
 

We can upload temporary files directly using the Move_uploaded_file function. Note that the second parameter $upload_dir= "saestor://". $domain. “/” . $dir.

Among them, $domain is the storage service name created in storage. $dir is the directory to store.

If you want to store the file under saestor://mydomain/dir1/dir2/dir3/. You can use the URL directly, rather than using the mkdir function to create it, because Stotage has automatically created the directory.

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.