__( "Failed to write file to disk." ),
__( "File upload stopped by extension." ));
- // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
+ // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
$test_form = true;
$test_size = true;
$test_upload = true;
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback );
+ $tmp_file = wp_tempnam($filename);
+
// Move the file to the uploads dir
- $new_file = $uploads['path'] . "/$filename";
- if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) )
+ if ( false === @ move_uploaded_file( $file['tmp_name'], $tmp_file ) )
return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );
+ // If a resize was requested, perform the resize.
+ $image_resize = isset( $_POST['image_resize'] ) && 'true' == $_POST['image_resize'];
+ $do_resize = apply_filters( 'wp_upload_resize', $image_resize );
+ $size = @getimagesize( $tmp_file );
+ if ( $do_resize && $size ) {
+ $old_temp = $tmp_file;
+ $tmp_file = image_resize( $tmp_file, (int) get_option('large_size_w'), (int) get_option('large_size_h'), 0, 'resized');
+ if ( ! is_wp_error($tmp_file) ) {
+ unlink($old_temp);
+ } else {
+ $tmp_file = $old_temp;
+ }
+ }
+
+ // Copy the temporary file into its destination
+ $new_file = $uploads['path'] . "/$filename";
+ copy( $tmp_file, $new_file );
+ unlink($tmp_file);
+
// Set correct file permissions
$stat = stat( dirname( $new_file ));
$perms = $stat['mode'] & 0000666;
}
/**
- * Handle sideloads, which is the process of retriving a media item from another server instead of
+ * Handle sideloads, which is the process of retrieving a media item from another server instead of
* a traditional media upload. This process involves sanitizing the filename, checking extensions
* for mime type, and moving the file to the appropriate directory within the uploads directory.
*
__( "Failed to write file to disk." ),
__( "File upload stopped by extension." ));
- // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
+ // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false;
$test_form = true;
$test_size = true;
}
/**
- * Unzip's a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction.
+ * Unzips a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction.
* Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present.
*
* Attempts to increase the PHP Memory limit to 256M before uncompressing,
return false;
if ( !$wp_filesystem->connect() )
- return false; //There was an erorr connecting to the server.
+ return false; //There was an error connecting to the server.
// Set the permission constants if not already set.
if ( ! defined('FS_CHMOD_DIR') )
/**
* Determines which Filesystem Method to use.
- * The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsoxkopen())
+ * The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())
*
* Note that the return value of this function can be overridden in 2 ways
* - By defining FS_METHOD in your <code>wp-config.php</code> file
if ( !empty($credentials) )
extract($credentials, EXTR_OVERWRITE);
if ( $error ) {
- $error_string = __('<strong>Error:</strong> There was an error connecting to the server, Please verify the settings are correct.');
+ $error_string = __('<strong>ERROR:</strong> There was an error connecting to the server, Please verify the settings are correct.');
if ( is_wp_error($error) )
$error_string = esc_html( $error->get_error_message() );
echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';