} } /** process each uploaded image **/ foreach (array_keys($upfiles) as $upfile) { $uplo = new uploadable("f_{$upfile}"); if (!$uplo->is_uploaded_file()) { if ($ACTION == OP_ADD) { // not req. } } else { // we got one - use $uplo to check it and save it and create DB vals as needed $uplo->unique_filename = true; $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, 'allowed' => 'web_images', 'ws_path' => CSHOP_MEDIA_URLPATH)); $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 $upfiles[$upfile] = array('sFilename' => $newfilename, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i')); } } } $imgcount = 0; /** try to insert or update image info to DB table media_prod **/ foreach ($upfiles as $upfile => $img_vals) {
$upfiles[$k] = array(); } } /** are there any actual files coming in? if so process *********************************/ $uplo_count = 0; if (count($upfiles)) { foreach (array_keys($upfiles) as $upfile) { $uplo = new uploadable($upfile); if (!$uplo->is_uploaded_file()) { #unset($upfiles[$upfile]); } else { // 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'];
} } /** process each uploaded image **/ foreach (array_keys($upfiles) as $upfile) { $uplo = new uploadable("f_{$upfile}"); if (!$uplo->is_uploaded_file()) { if ($ACTION == OP_ADD) { // not req. } } else { // we got one - use $uplo to check it and save it and create DB vals as needed $uplo->unique_filename = true; $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($colmap[$upfile][3]); $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 $upfiles[$upfile] = array('sFilename' => $newfilename, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i')); } } } $imgcount = 0; /** try to insert or update image info to DB table media_prod **/ foreach ($upfiles as $upfile => $img_vals) {