// イメージ削除処理.
//

// 必須パラメータが存在しない場合は処理しない.
if( useString( params['imgName'] ) == false ||
    useString( params['id'] ) == false ) {
    throw new Exception( "not params" ) ;
}

var paramId = ""+(( useString( params['id'] ) == false ) ? "0" : params['id']) ;
var dir = "public/upimg/" ;
var file = params['imgName'] ;
if( startsWith( file,paramId+"/" ) == false ) {
    throw new Exception( "error[imgName]:" + params['imgName'] ) ;
}

dir = dir + paramId + "/" ;
file = file.substring( paramId.length+1 ) ;
Io.deleteFile( dir+file ) ;
FileList.remove( dir,file ) ;


// 元の画面にリダイレクト.
setSuccessMessage( "画像削除[" + file + "]が完了しました" ) ;
redirect( "/owwg/selectImage?"+$mp(params) ) ;
