- Added predefined constants for the upload errors.

- Removed the debugging error (not useful for end-users)
This commit is contained in:
foobar 2002-07-12 01:49:58 +00:00
parent 87e0a4baf5
commit ed58d3a235
3 changed files with 18 additions and 6 deletions

View File

@ -80,6 +80,7 @@
#endif /* defined(ZEND_MULTIBYTE) && defined(HAVE_MBSTRING) */
#include "SAPI.h"
#include "rfc1867.h"
/* }}} */
#ifndef ZTS
@ -973,6 +974,7 @@ int php_module_startup(sapi_module_struct *sf)
REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, sizeof(PHP_CONFIG_FILE_PATH)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_SHLIB_SUFFIX", PHP_SHLIB_SUFFIX, sizeof(PHP_SHLIB_SUFFIX)-1, CONST_PERSISTENT | CONST_CS);
php_output_register_constants(TSRMLS_C);
php_rfc1867_register_constants(TSRMLS_C);
if (php_startup_ticks(TSRMLS_C) == FAILURE) {
php_printf("Unable to start PHP ticks\n");

View File

@ -55,11 +55,20 @@
#define MAX_SIZE_OF_INDEX sizeof("[tmp_name]")
/* Errors */
#define UPLOAD_ERROR_A 1 /* Uploaded file exceeded upload_max_filesize */
#define UPLOAD_ERROR_B 2 /* Uploaded file exceeded MAX_FILE_SIZE */
#define UPLOAD_ERROR_C 3 /* Only partiallly uploaded */
#define UPLOAD_ERROR_D 4 /* No file uploaded */
#define UPLOAD_ERROR_E 5 /* Uploaded file size 0 bytes */
#define UPLOAD_ERROR_OK 0 /* File upload succesful */
#define UPLOAD_ERROR_A 1 /* Uploaded file exceeded upload_max_filesize */
#define UPLOAD_ERROR_B 2 /* Uploaded file exceeded MAX_FILE_SIZE */
#define UPLOAD_ERROR_C 3 /* Partially uploaded */
#define UPLOAD_ERROR_D 4 /* No file uploaded */
void php_rfc1867_register_constants(TSRMLS_D)
{
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_OK", UPLOAD_ERROR_OK, CONST_CS | CONST_PERSISTENT);
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_INI_SIZE", UPLOAD_ERROR_A, CONST_CS | CONST_PERSISTENT);
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_FORM_SIZE", UPLOAD_ERROR_B, CONST_CS | CONST_PERSISTENT);
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_PARTIAL", UPLOAD_ERROR_C, CONST_CS | CONST_PERSISTENT);
REGISTER_MAIN_LONG_CONSTANT("UPLOAD_ERR_NO_FILE", UPLOAD_ERROR_D, CONST_CS | CONST_PERSISTENT);
}
static void add_protected_variable(char *varname TSRMLS_DC)
{
@ -788,7 +797,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
#ifdef DEBUG_FILE_UPLOAD
if(strlen(filename) > 0 && total_bytes == 0) {
sapi_module.sapi_error(E_WARNING, "Uploaded file size 0 - file [%s=%s] not saved", param, filename);
cancel_upload = UPLOAD_ERROR_E;
cancel_upload = 5;
}
#endif

View File

@ -8,5 +8,6 @@
SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler);
void destroy_uploaded_files_hash(TSRMLS_D);
void php_rfc1867_register_constants(TSRMLS_D);
#endif /* RFC1867_H */