All pastes #68210 Raw Edit

Untitled

public text v1 · immutable
#68210 ·published 2006-06-21 06:31 UTC
rendered paste body
$image_max_width    = "900";     # in pixels
$image_max_height    = "900";    # in pixels

// Where the file is going to be placed

$id1 = $_SESSION['ID'];
if (!is_dir("images/$id1"))  { mkdir("images/$id1");}



$target_path = "images/$id1/";


/* Add the original filename to our target path. Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

// This is how we will get the temporary file...
//$_FILES['uploadedfile']['tmp_name'];





if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
	$query = mysql_query("INSERT INTO items (image)");
	CreateThumb($target_path,"120","120","thumb_$target_path");
} else{

    $target_path = 'images/noimage.jpg';
}


$query = sprintf("INSERT INTO items (userId,name,type,description,price,date,image,thumb) VALUES('". $_SESSION['ID'] ."','%s','%s','%s','%s', NOW(),'%s','%s')", mysql_real_escape_string($name),mysql_real_escape_string($type),mysql_real_escape_string($description),mysql_real_escape_string($price),mysql_real_escape_string($target_path),mysql_real_escape_string("thumb_" . $target_path . ""));
mysql_query($query) or die("Error in query: $query.  ". mysql_error());
$idNum = mysql_insert_id();


?>