Trouble to help the picture can not be uploaded for what reason?

Source: Internet
Author: User
The database can write information, but the picture is not uploaded to the server, do not know what the reason, trouble God help to see
/**
* Shop Edit
*/
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);
/**
* Check the store level
*/
$model _grade = Model (' Store_grade ');
$grade _array = $model _grade->getonegrade (intval ($_post[' grade_id '));
if (Empty ($grade _array)) {
ShowMessage ($lang [' please_input_store_level ']);
}
/**
* Upload a store ad image
*/
if (!empty ($_files[' shopad ' [' name '])) {
$upload = new UploadFile ();
$upload->set (' Default_dir ', Attach_common);
$result = $upload->upfile (' Shopad ');
}
/**
* 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 if the store name exists
ShowMessage ($lang [' store_name_exists ']);
}
if ($_post[' store_state '] = = ' 0 ') {
/**
* Modify the status of all items in the store according to 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 {
/**
* When the store is opened, the product is not automatically listed and requires manual operation
*/
$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[' Shopad ')) {
$update _array[' shopad '] = $_post[' Shopad '];
}
$result = $model _store->storeupdate ($update _array);

if ($result) {

/**
* Judging there is no previous picture, if there is then delete
*/
if (!empty ($_post[' Shopad ')) &&!empty ($_post[' Shopad ']) {
@unlink (BasePath.DS.ATTACH_COMMON. ds.$_post[' Shopad ');
}
SMS notice in the station
if ($_post[' store_state ') = = 0) {
Get store Info
$store _info = $model _store->shopstore (Array (
' store_id ' =>$_post[' store_id ']
));
Admin Close Store
Send a close notification message to the shopkeeper
$msg _code = ' msg_toseller_store_closed_notify ';
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 ']);
}
}
/**
* Pick up store information
*/
$condition [' store_id '] = intval ($_get[' store_id ');
$store _array = $model _store->shopstore ($condition);
if (Empty ($store _array)) {
ShowMessage ($lang [' store_no_exist ']);
}
/**
* Organize store contents
*/
$store _array[' store_end_time ' = $store _array[' store_end_time ']?date (' y-m-d ', $store _array[' Store_end_time ']): ';
/**
* Shop 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 '];
}
}
/**
* Shop Level
*/
$model _grade = Model (' Store_grade ');
$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 pictures of shop ads * *
if (!empty ($_files[' shopad ' [' name '])) {
$upload = new UploadFile ();
$upload->set (' Default_dir ', Attach_common);
$result = $upload->upfile (' Shopad ');
}
/**
* Determine if there is no previous picture, if any then delete */
if (!empty ($_post[' Shopad ')) &&!empty ($_post[' Shopad ']) {
@unlink (BasePath.DS.ATTACH_COMMON. ds.$_post[' Shopad ');
}
Your judgment delete the image after uploading? That's definitely going to erase the previous upload.

/**
* Upload pictures of shop ads * *
if (!empty ($_files[' shopad ' [' name '])) {
$upload = new UploadFile ();
$upload->set (' Default_dir ', Attach_common);
$result = $upload->upfile (' Shopad ');
}
/**
* Determine if there is no previous picture, if any then delete */
if (!empty ($_post[' Shopad ')) &&!empty ($_post[' Shopad ']) {
@unlink (BasePath.DS.ATTACH_COMMON. ds.$_post[' Shopad ');
}
Your judgment delete the image after uploading? That's definitely going to erase the previous upload.

I have put * to judge there is no previous picture, if there is delete */below the code deleted, or can not upload, do not know what the reason!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.