Changeset 13290
- Timestamp:
- 02/22/2010 04:54:51 PM (15 years ago)
- Location:
- trunk/wp-admin/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/file.php
r13223 r13290 228 228 function wp_handle_upload( &$file, $overrides = false, $time = null ) { 229 229 // The default error handler. 230 if ( ! function_exists( 'wp_handle_upload_error' ) ) {230 if ( ! function_exists( 'wp_handle_upload_error' ) ) { 231 231 function wp_handle_upload_error( &$file, $message ) { 232 232 return array( 'error'=>$message ); … … 263 263 $test_form = true; 264 264 $test_size = true; 265 $test_upload = true; 265 266 266 267 // If you override this, you must provide $ext and $type!!!! … … 274 275 // A correct form post will pass this test. 275 276 if ( $test_form && (!isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) ) 276 return $upload_error_handler($file, __( 'Invalid form submission.' ));277 return call_user_func($upload_error_handler, $file, __( 'Invalid form submission.' )); 277 278 278 279 // A successful upload will pass this test. It makes no sense to override this one. 279 280 if ( $file['error'] > 0 ) 280 return $upload_error_handler($file, $upload_error_strings[$file['error']] );281 return call_user_func($upload_error_handler, $file, $upload_error_strings[$file['error']] ); 281 282 282 283 // A non-empty file will pass this test. 283 if ( $test_size && !($file['size'] > 0 ) ) 284 return $upload_error_handler( $file, __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' )); 284 if ( $test_size && !($file['size'] > 0 ) ) { 285 if ( is_multisite() ) 286 $error_msg = __( 'File is empty. Please upload something more substantial.' ); 287 else 288 $error_msg = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ); 289 return call_user_func($upload_error_handler, $file, $error_msg); 290 } 285 291 286 292 // A properly uploaded file will pass this test. There should be no reason to override this one. 287 if ( ! @ is_uploaded_file( $file['tmp_name'] ) )288 return $upload_error_handler($file, __( 'Specified file failed upload test.' ));293 if ( $test_upload && ! @ is_uploaded_file( $file['tmp_name'] ) ) 294 return call_user_func($upload_error_handler, $file, __( 'Specified file failed upload test.' )); 289 295 290 296 // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter. … … 295 301 296 302 if ( ( !$type || !$ext ) && !current_user_can( 'unfiltered_upload' ) ) 297 return $upload_error_handler($file, __( 'File type does not meet security guidelines. Try another.' ));303 return call_user_func($upload_error_handler, $file, __( 'File type does not meet security guidelines. Try another.' )); 298 304 299 305 if ( !$ext ) … … 308 314 // A writable uploads dir will pass this test. Again, there's no point overriding this one. 309 315 if ( ! ( ( $uploads = wp_upload_dir($time) ) && false === $uploads['error'] ) ) 310 return $upload_error_handler( $file, $uploads['error'] );316 return call_user_func($upload_error_handler, $file, $uploads['error'] ); 311 317 312 318 $filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); … … 314 320 // Move the file to the uploads dir 315 321 $new_file = $uploads['path'] . "/$filename"; 316 if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) {322 if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) 317 323 return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) ); 318 }319 324 320 325 // Set correct file permissions -
trunk/wp-admin/includes/media.php
r13283 r13290 178 178 * @since unknown 179 179 * 180 * @param unknown_type $file_id181 * @param unknown_type $post_id182 * @param unknown_type $post_data183 * @ return unknown184 * /185 function media_handle_upload($file_id, $post_id, $post_data = array()) { 186 $overrides = array('test_form'=>false); 180 * @param string $file_id Index into the {@link $_FILES} array of the upload 181 * @param int $post_id The post ID the media is associated with 182 * @param array $post_data allows you to overwrite some of the attachment 183 * @param array $overrides allows you to override the {@link wp_handle_upload()} behavior 184 * @return int the ID of the attachment 185 */ 186 function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false )) { 187 187 188 188 $time = current_time('mysql'); … … 462 462 $html = $attachment['post_title']; 463 463 if ( !empty($attachment['url']) ) { 464 $rel = ''; 464 465 if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) ) 465 466 $rel = " rel='attachment wp-att-" . esc_attr($send_id)."'";
Note: See TracChangeset
for help on using the changeset viewer.