Forum Moderators: coopster
The input on the form is as follows:
<tr>
<td class="main" valign="top"><?php echo TEXT_ADS_IMAGE;?></td>
<td class="main"><?php echo tep_draw_file_field('ads_image_file') . ' Current Image: <b>'.(isset($bInfo->ads_image)? $bInfo->ads_image : '').'</b>';?></td>
</tr>
Which yields this in HTML:
<tr>
<td class="main" valign="top">Image:</td>
<td class="main"><input type="file" name="ads_image_file"> Current Image: <b></b></td>
</tr>
Now my understanding of the image upload process is that PHP will take the file and upload it to a temp directory and if that succeeds, the PHP osCommerce script will copy that temp file to a location specified in the script. Like I said, it class and functions for the upload work for the other uploading tools.
So here's a two part question.
First, when I try to view the value of the field $ads_image_file I get the temp file name rather than the actual filename. Why?
Second, while the script runs without errors, the file never makes it to it's destination. The particular section I'm testing updates an existing db record. Text edits are completed without error. Here's the pertinent code for that section:
if (isset($HTTP_POST_VARS['ads_id'])) $ads_id = tep_db_prepare_input($HTTP_POST_VARS['ads_id']);
$ads_title = tep_db_prepare_input($HTTP_POST_VARS['ads_title']);
$ads_copy = tep_db_prepare_input($HTTP_POST_VARS['ads_copy']);
$ads_product_url = tep_db_prepare_input($HTTP_POST_VARS['ads_product_url']);
$ads_image = tep_db_prepare_input($ads_image_file);
$db_image_location = '';$ad_error = false;
if (empty($ads_title)) {
$messageStack->add(ERROR_AD_TITLE_REQUIRED, 'error');
$ad_error = true;
}if (empty($ads_copy)) {
if (empty($ads_image)) {
$ads_image = new upload('ads_image');
$ads_image->set_destination(DIR_FS_CATALOG_ADS . $ads_image);
if ( ($ads_image->parse() == false) ¦¦ ($ads_image->save() == false) ) {
$ad_error = true;
}
}
}
The global $_FILES [php.net] exists as of PHP 4.1.0 (Use $HTTP_POST_FILES instead if using an earlier version). These arrays will contain all the uploaded file information.
Either way, glad you got it sorted :)