The is_upload_space_available() WordPress PHP function determines if there is any upload space left in the current blog’s quota.
Usage
$is_available = is_upload_space_available();
This example checks if there’s available space for uploading and returns true if space is available, and false if not.
Parameters
- None
More information
See WordPress Developer Resources: is_upload_space_available()
Examples
Checking if upload space is available
This example checks if there’s available space for uploading and displays a message accordingly.
if (is_upload_space_available()) {
echo "Upload space is available!";
} else {
echo "No upload space left!";
}
Displaying a custom message when upload space is unavailable
This example shows a custom message when there’s no available space for uploading.
if (!is_upload_space_available()) {
echo "Sorry, we've run out of space for uploads.";
}
Hiding the upload form when there’s no available space
This example hides the upload form when the upload space is not available.
if (is_upload_space_available()) {
// Display the upload form
// Code for displaying the upload form goes here
} else {
echo "Upload space is full!";
}
Enabling a button only when there’s available space
This example enables an “Upload” button only when there’s available space for uploading.
$is_available = is_upload_space_available(); $disabled = $is_available ? '' : 'disabled'; echo "<button $disabled>Upload</button>";
Logging upload space availability
This example logs a message in the debug.log file about the availability of the upload space.
if (is_upload_space_available()) {
error_log("Upload space is available!");
} else {
error_log("No upload space left!");
}