Discuz! supports storing user-uploaded attachments on a remote FTP server instead of local disk. By pairing this built-in feature with OSS FTP (ossftp), you can route all attachment uploads directly to an OSS bucket—without changing how Discuz! works.
Prerequisites
Before you begin, ensure that you have:
A public-read OSS bucket. The bucket access control list (ACL) must be set to public-read. Private buckets are not supported for this integration—Discuz! retrieves attachment URLs directly from OSS, so a private bucket will break image and file display. For setup instructions, see Create a bucket. This guide uses a bucket named
test-hz-jh-002in the China (Hangzhou) region as an example.ossftp installed and running. ossftp acts as the FTP gateway between Discuz! and OSS. For installation instructions, see Installation.
A Discuz! forum. Download Discuz! from the Discuz! official website. This guide uses Discuz! X3.1 as an example.
Your AccessKey ID and AccessKey secret. These credentials are used as the FTP username and password. To retrieve them, see Obtain an AccessKey pair.
Configure the remote attachment settings
Log in to the Discuz! admin panel using an administrator account.
Click Global, then click Upload Settings
Click the Remote Attachment
Configure the parameters as described in the following table.
Parameter Example value Description Enable remote attachment Yes Set to Yes to enable remote attachment storage. Enable SSL connection No Whether to use SSL for the FTP connection. FTP server 127.0.0.1Address of the server running ossftp. If ossftp runs on the same machine as Discuz!, enter 127.0.0.1.FTP server port number 2048Port that ossftp listens on. Default: 2048.FTP account Y6IoUOZReouXvWaXuwjvDch9******/examplebucketFTP username in the format <AccessKeyID>/<BucketName>. The AccessKey ID must belong to an account that is granted permissions to access the bucket. To use a custom username instead, see Create custom logon users.FTP password sRaQg0i3SH9EqYXJSL1hlaR******Your AccessKey secret. To use a custom password instead, see Create custom logon users. Passive mode connection Yes Must be set to Yes for ossftp compatibility. Remote upload directory .Path prefix for uploaded files in OSS. A period ( .) places files in the bucket root directory.Remote access URL https://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.comPublic URL of your bucket, in the format https://<BucketName>.<Endpoint>.FTP timeout (seconds) 0FTP connection timeout. 0uses the server default.
Test and verify the configuration
Test the connection
Click Test Remote Attachment. Discuz! sends a test request to ossftp. If the test passes, the configuration is valid and you can proceed.
If the test fails, check the following:
ossftp is running and accessible on the configured host and port.
The bucket ACL is set to public-read, not private.
Confirm uploads reach OSS
Post a new article in Discuz! and attach an image.
After posting, right-click the image and choose Open Link in New Tab.
Check the URL in the new tab. If the URL matches the format
http(s)://<BucketName>.<Endpoint>/<path>/<filename>, the attachment was uploaded to OSS successfully. For example:https://test-hz-jh-002.oss-cn-hangzhou.aliyuncs.com/forum/201512/18/171012mzvkku2z3na2w2wa.jpg