Why can't images be uploaded? The database can write information, but the image is not uploaded to the server. why?
/**
* Shop Editing
*/
Public function store_editOp (){
/**
* Read language packs
*/
$ Lang = Language: getLangContent ();
$ Model_store = Model ('store ');
/**
* Save
*/
If (chksubmit ()){
/**
* Upload images
*/
$ Upload = new UploadFile ();
$ Upload-> set ('default _ dir', ATTACH_COMMON );
/**
* Store grade review
*/
$ Model_grade = Model ('store _ grad ');
$ Grade_array = $ model_grade-> getOneGrade (intval ($ _ POST ['grade _ id']);
If (empty ($ grade_array )){
ShowMessage ($ lang ['Please _ input_store_level ']);
}
/**
* Upload shop advertisement images
*/
If (! Empty ($ _ FILES ['shopped'] ['name']) {
$ Upload = new UploadFile ();
$ Upload-> set ('default _ dir', ATTACH_COMMON );
$ Result = $ upload-> upfile ('shopped ');
}
/**
* End time
*/
$ Time = '';
If (trim ($ _ POST ['end _ time'])! = ''){
$ Time = strtotime ($ _ POST ['end _ time']);
}
$ Update_array = array ();
$ Update_array ['store _ id'] = intval ($ _ POST ['store _ id']);
$ Update_array ['store _ owner_card '] = trim ($ _ POST ['store _ owner_card']);
$ Update_array ['store _ name'] = trim ($ _ POST ['store _ name']);
$ Update_array ['SC _ id'] = intval ($ _ POST [' SC _ id']);
$ Update_array ['area _ id'] = intval ($ _ POST ['area _ id']);
$ Update_array ['area _ info'] = trim ($ _ POST ['area _ info']);
$ Update_array ['store _ address'] = trim ($ _ POST ['store _ address']);
$ Update_array ['store _ zip'] = trim ($ _ POST ['store _ zip']);
$ Update_array ['store _ Tel'] = trim ($ _ POST ['store _ Tel']);
$ Update_array ['grade _ id'] = intval ($ _ POST ['grade _ id']);
$ Update_array ['store _ end_time '] = $ time;
$ Update_array ['store _ state'] = intval ($ _ POST ['store _ state']);
$ Store_info = $ model_store-> shopStore (array ('store _ name' => $ update_array ['store _ name']);
If ($ store_info ['store _ id']> 0 & $ store_info ['store _ id']! = $ Update_array ['store _ id']) {// check whether the store name exists
ShowMessage ($ lang ['store _ name_exists ']);
}
If ($ _ POST ['store _ state'] = '0 '){
/**
* Modify the status of all commodities in the store based on the store status.
*/
$ Model_goods = Model ('Goods ');
$ Model_goods-> updateGoodsStoreStateByStoreId ($ update_array ['store _ id'], 'close ');
$ Update_array ['store _ close_info '] = trim ($ _ POST ['store _ close_info']);
$ Update_array ['store _ recommend'] = 0;
} Else {
/**
* Manual operations are required if the product is not automatically shelved after the store is opened
*/
$ Update_array ['store _ close_info '] = '';
$ Update_array ['store _ recommend'] = intval ($ _ POST ['store _ recommend']);
}
$ Update_array ['name _ auth'] = intval ($ _ POST ['name _ auth']);
$ Update_array ['store _ auth'] = intval ($ _ POST ['store _ auth']);
$ Update_array ['store _ sort '] = intval ($ _ POST ['store _ sort']);
If (! Empty ($ _ POST ['shopped']) {
$ Update_array ['thinkpad '] =_ _ POST ['thinkpad'];
}
$ Result = $ model_store-> storeUpdate ($ update_array );
If ($ result ){
/**
* Determine whether there is any previous image. If yes, delete it.
*/
If (! Empty ($ _ POST ['shopped']) &! Empty ($ _ POST ['shopped']) {
@ Unlink (BasePath. DS. ATTACH_COMMON.DS. $ _ POST ['shop']);
}
// Intra-site short message notification
If ($ _ POST ['store _ state'] = 0 ){
// Obtain store information
$ Store_info = $ model_store-> shopStore (array (
'Store _ id' = >$ _ POST ['store _ id']
));
// The postmaster closes the store.
// Send a closing notification message to the shopkeeper
$ Msg_code = 'MSG _ toseller_store_closed_policy ';
// Content
$ Param = array ('reason '= >$ _ POST ['store _ close_info']);
Self: send_notice ($ store_info ['Member _ id'], $ msg_code, $ param );
}
$ Url = array (
Array (
'URL' => 'index. php? Act = store & op = store ',
'MSG '=> $ lang ['back _ store_list'],
),
Array (
'URL' => 'index. php? Act = store & op = store_edit & store_id = '. intval ($ _ POST ['store _ id']),
'MSG '=> $ lang ['countinue _ add_store'],
),
);
ShowMessage ($ lang ['update _ store_ OK '], $ url );
} Else {
ShowMessage ($ lang ['update _ fail_fail ']);
}
}
/**
* Store information retrieval
*/
$ Condition ['store _ id'] = intval ($ _ GET ['store _ id']);
$ Store_array = $ model_store-> shopStore ($ condition );
If (empty ($ store_array )){
ShowMessage ($ lang ['store _ no_exist ']);
}
/**
* Sort store content
*/
$ Store_array ['store _ end_time '] = $ store_array ['store _ end_time']? Date ('Y-m-D', $ store_array ['store _ end_time ']): '';
/**
* Store category
*/
$ Model_store_class = Model ('store _ class ');
$ Parent_list = $ model_store_class-> getTreeClassList (2 );
If (is_array ($ parent_list )){
Foreach ($ parent_list as $ k => $ v ){
$ Parent_list [$ k] ['SC _ name'] = str_repeat ("", $ v ['deep'] * 2). $ v ['SC _ name'];
}
}
/**
* Store grade
*/
$ Model_grade = Model ('store _ grad ');
$ Grade_list = $ model_grade-> getGradeList ();
Tpl: output ('grade _ list', $ grade_list );
Tpl: output ('class _ list', $ parent_list );
Tpl: output ('store _ array', $ store_array );
Tpl: showpage ('store. edit ');
}
Reply to discussion (solution)
/**
* Upload shop advertisement images */
If (! Empty ($ _ FILES ['shopped'] ['name']) {
$ Upload = new UploadFile ();
$ Upload-> set ('default _ dir', ATTACH_COMMON );
$ Result = $ upload-> upfile ('shopped ');
}
/**
* Determine whether there are any previous images. If yes, delete the images */
If (! Empty ($ _ POST ['shopped']) &! Empty ($ _ POST ['shopped']) {
@ Unlink (BasePath. DS. ATTACH_COMMON.DS. $ _ POST ['shop']);
}
Are you sure you want to delete the image after uploading? It will definitely delete the previously uploaded files.
/**
* Upload shop advertisement images */
If (! Empty ($ _ FILES ['shopped'] ['name']) {
$ Upload = new UploadFile ();
$ Upload-> set ('default _ dir', ATTACH_COMMON );
$ Result = $ upload-> upfile ('shopped ');
}
/**
* Determine whether there are any previous images. If yes, delete the images */
If (! Empty ($ _ POST ['shopped']) &! Empty ($ _ POST ['shopped']) {
@ Unlink (BasePath. DS. ATTACH_COMMON.DS. $ _ POST ['shop']);
}
Are you sure you want to delete the image after uploading? It will definitely delete the previously uploaded files.
I have deleted the code * to check whether there are any previous images. If yes, the code below is deleted. I still cannot upload the images. I don't know why!