How to use the storage service of SAE _ PHP Tutorial

Source: Internet
Author: User
How to use the storage service of SAE. Using the storage service of SAE, I finally understood how to use the storage of sae. Because sae does not support file permission settings, all code files are uncounted. However, sae provides the storage service usage of the special SAE.

Today, I finally learned how to use sae storage.

Because sae does not support file permission settings, all code files are uncounted. However, sae provides a particularly good distributed file storage service for storing persistent files. It is actually used to store website material files, slices, files, and so on.

Therefore, you can use sae when you need to store file data.

There are two solutions for using sae.

An official solution is:

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

There is also a method I saw in the sae app store, which contains a synthetic wordpress for sae.

We can see the detailed Code. I now paste my simple test code below: (only to implement storage, not applicable to development scenarios)

The code is as follows:









$ 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"]."
";
}
Else
{
Echo "Upload:". $ _ FILES ["file"] ["name"]."
";
Echo "Type:". $ _ FILES ["file"] ["type"]."
";
Echo "Size:". ($ _ FILES ["file"] ["size"]/1024). "Kb
";
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 directly use the move_uploaded_file function to upload temporary files. Note that the second parameter $ upload_dir = "saestor: //". $ domain. "/". $ dir.

$ Domain is the name of the storage service created in storage. $ Dir is the directory to store.

To store the file in saestor: // mydomain/dir1/dir2/dir3. You can directly use this url without using the mkdir function, because the stotage has automatically created this directory.

Parse finally understands how to use the storage of sae. Because sae does not support file permission settings, all code files are uncounted. But sae provides special...

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.