/* Upload an image and return the uploaded image name */ function uploadProductImage($inputName, $uploadDir) { $image = $_FILES[$inputName]; $imagePath = ''; $thumbnailPath = '';
// if a file is given if (trim($image['tmp_name']) != '') { $ext = substr(strrchr($image['name'], "."), 1); //$extensions[$image['type']];
// generate a random new file name to avoid name conflict $imagePath = md5(rand() * time()) . ".$ext";
// make sure the image width does not exceed the // maximum allowed width if (LIMIT_PRODUCT_WIDTH && $width > MAX_PRODUCT_IMAGE_WIDTH) { $result = createThumbnail($image['tmp_name'], $uploadDir . $imagePath, MAX_PRODUCT_IMAGE_WIDTH); $imagePath = $result;
print_r() just output some human-readable info about a variable, it's not really intended to be part of a function or to be used programatically. It's more for debugging and as an aid in visualizing array structures.