// we got one - use $uplo to check it and save it and create DB vals as needed $uplo->preserve_original_name = true; $uplo->setErrorHandling(PEAR_ERROR_RETURN); // tell $uplo what kind of image we expect and where to put it: $uplo->params(array('path' => CSHOP_MEDIA_FULLPATH, 'ws_path' => CSHOP_MEDIA_URLPATH) + $colmap[$upfile][3]); // set other possible params for uplo from the colmap attribs section [3] // todo something better */ $res = $uplo->save_upload(); if (PEAR::isError($res)) { $errs[] = $res->getMessage(); } else { // get the name of the new file $newfilename = $uplo->get_newname(); // create a thumbnail right here: // vals to be put in DB - will be given the rest of the column names below $upfiles[$upfile] = array('' => $newfilename, 'mimetype' => $uplo->get_filetype(), 'size' => $uplo->get_filesize(), 'dims' => $uplo->get_img_dims()); // call resizing or thumbnailing methods as needed ((((())))))))))))))))))))))) if (isset($uplo->params['thumb_method'])) { // todo $uplo should do this too $method = $uplo->params['thumb_method']; $stretch = new imagestretcher(CSHOP_MEDIA_FULLPATH . '/' . $newfilename); if (!method_exists($stretch, $method)) { $errs[] = "imagestretcher::{$method}() is not a valid method."; } else { $stretch->{$method}($uplo->params['thumb_w'], $uplo->params['thumb_h']); $thumb_name = $stretch->save_to_file(CSHOP_MEDIA_FULLPATH . '/_th_' . $newfilename, 'png'); $upfiles[$upfile]['thumb_name'] = $thumb_name; $upfiles[$upfile]['thumb_dims'] = $stretch->get_thumb_dims(); } } if (isset($uplo->params['resize_method'])) {
} elseif (defined('THUMB_EXACT_W') and defined('THUMB_EXACT_H')) { $thumb1 = $uplo->save_thumbnail(THUMB_EXACT_W, THUMB_EXACT_H, 'shrink_to_size'); $needs_thumb = true; } if ($needs_thumb && empty($thumb1)) { $thumb1 = $newfilename; } if (PEAR::isError($thumb1)) { $errs[] = $thumb1->getMessage(); } else { $vals['system_location'] = CSHOP_MEDIA_URLPATH; $vals['filename_large'] = $newfilename; $vals['dims_large'] = $img_dims; $vals['filename_thumb'] = $thumb1; $vals['dims_thumb'] = $uplo->get_thumb_dims(); $vals['mime_type'] = $uplo->get_filetype(); if (isset($zoom_file)) { $vals['filename_zoom'] = basename($zoom_file); } } } } if (!count($errs)) { if ($ACTION == OP_ADD) { $vals['id'] = $pdb->nextId($tablename); $res = $pdb->autoExecute($tablename, $vals, DB_AUTOQUERY_INSERT); } elseif ($ACTION == OP_EDIT) { $where = sprintf("id = %d", $reqid); $res = $pdb->autoExecute($tablename, $vals, DB_AUTOQUERY_UPDATE, $where); } if (PEAR::isError($res)) {