我只需要一些帮助来访问文件输入值。我正在使用CSCART appliacation。它就像Magento。我的问题是我创建了3个具有唯一名称的文件输入。每次我将它们的值传递给数组。但是当我检查数组值时。缺少3个文件输入。但是当我将文件输入更改为文本框时。我可以访问它。我只是不知道我的代码中的错误在哪里。在这里。
//the company_data[contractor_data][banner] is the name of my file
<tr>
<td></td>
<td colspan="3"><input type="file" name="company_data[contractor_data][banner]" id="banner" /></td>
</tr>
<tr>
<td></td>
<td colspan="3"><span style="color:#9c3535; font-size:12px">(must be 576x72 px : JPG,PNG or GIF)</span></td>
</tr>
<tr>
<td><label for="text_a" class="cm-trim">{'Text Information'}:</label></td>
<td colspan="3"><textarea id="text_a" name="company_data[contractor_data][banner_text]" cols="55" rows="8" class="cm-wysiwyg input-textarea-long">{$company_data.banner_text}</textarea></td>
</tr>
.....
在我的功能中
function fn_save_contractor_data($company_id = 0,$contractor_data = array()){
if(empty($contractor_data) || $company_id == 0){
return false;
}
fn_print_die($contractor_data); //this will print all my form values
if(db_get_field("SELECT COUNT(company_id) FROM ?:contractors WHERE company_id = ?i",$company_id) > 0 ){
return db_query("UPDATE ?:contractors SET ?u WHERE company_id = ?i",$contractor_data,$company_id);
}else{
$contractor_data['company_id'] = $company_id;
return db_query("INSERT INTO ?:contractors ?e",$contractor_data);
}
}
输出结果为:
Array
(
[shop_tel] => 091254515421
[shop_holiday] => Regular Holiday
[shop_business_hours] => Business Hours
[contractor_name] => San Miguel Cor.
[representative_firstname] => Danding1
[representative_lastname] => Cojuangco
[contractor_tel] => 1234343
[contractor_cellphone] => 098712
[contractor_fax] => fax
[contractor_email] => dennis@tavolozza.ph
[contractor_website] =>
[contractor_building] =>
[contractor_address] => address
[contractor_city] => town
[contractor_country] => PH
[contractor_state] => MNL
[contractor_zipcode] => 1234
[bank_name] => PNB
[branch] => branch
[bank_account_name] => account
[account_number] => account number
[opening_date] => 1357228800
[is_credit_card] => Y
[is_vat_included] => I
[point_ratio] => 1
[is_back_order] => Y
[is_international_shipping] => Y
[free_shipping_amount] => 100.00
[return] => Y
[return_day] => 7
[has_gift_wrapping] => Y
[has_gift_card] => Y
[has_message] => Y
[usergroup_ids] => 0
[feature_comparison] => Y
[company_description] =>
[banner_text] => banner test //this will be the place where the banner should be.
[sign_a_text] => sign a.1
[sign_b_text] => sign b.1.2
)
好的,这是我的代码。对不起我的疑惑,但我希望你能给我任何想法。我无法发现我的错误。这是我第一次使用这个应用程序。所以我很难调试它。
答案 0 :(得分:1)
您需要使用全局数组$ _FILES来访问上传的文件。
作为示例 - 请参阅函数fn_attach_image_pairs
。此函数调用fn_filter_uploaded_data
。您可以使用此功能来处理上传的文件。