Today I finally figured out how to use SAE's storage.
Here is an overview address for the SAE storage:
Http://sae.sina.com.cn/doc/php/storage.html.
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.
Official API Document Address: http://apidoc.sinaapp.com/sae/SaeStorage.html
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)
The code is as follows |
Copy Code |
<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"/> </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.