function start_upload( $file_name, $destination_folder, $watermark = 0, $limit_width = "", $limit_height = "", $edit_filename = "", $edit_pre_filename = "" ) { global $mymps_global; global $timestamp; if ( !is_uploaded_file( $_FILES[$file_name]['tmp_name'] ) ) { write_msg( "请重新选择您要上传的图片!" ); } $file = $_FILES[$file_name]; @createdir( MYMPS_UPLOAD.$destination_folder ); $file_name = $file['tmp_name']; $pinfo = pathinfo( $file['name'] ); $ftype = $pinfo['extension']; $fname = $pinfo[basename]; if ( empty( $edit_filename ) && empty( $edit_pre_filename ) ) { $destination_file = $timestamp.random( ).".".$ftype; $destination = MYMPS_UPLOAD.$destination_folder.$destination_file; $small_destination = MYMPS_UPLOAD.$destination_folder."pre_".$destination_file; } else { $destination = MYMPS_ROOT.$edit_filename; $small_destination = MYMPS_ROOT.$edit_pre_filename; $forbidarray = array( MYMPS_ROOT."/p_w_picpaths/logo.gif", MYMPS_ROOT."/p_w_picpaths/nopic.gif", MYMPS_ROOT."/p_w_picpaths/nophoto.jpg", MYMPS_ROOT."/p_w_picpaths/noavatar.gif", MYMPS_ROOT."/p_w_picpaths/noavatar_small.gif" ); if ( !in_array( $destination, $forbidarray ) || $destination != MYMPS_ROOT ) { @unlink( $destination ); } if ( !in_array( $small_destination, $forbidarray ) || $destination != MYMPS_ROOT ) { @unlink( $small_destination ); } unset( $forbidarray ); } if ( file_exists( $destination ) ) { write_msg( "同名图片已存在,请重新选择您要上传的图片!" ); } if ( !move_uploaded_file( $file_name, $destination ) ) { write_msg( "图片上传失败,请重新选择您要上传的图片!" ); } |