upload file, image_upload_function

From: Date: Sat, 25 Oct 2008 22:20:37 +0000
Subject: upload file, image_upload_function
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2878@lists.php.net to get a copy of this message
I'm new to php and apache. I'm trying to upload some files on my server using a form and mysql. I went through pages on the net and got many samples, but I don't know how to get it done. My concept is to give some opportunity to some users with a privilege to upload images to create their own pages through the cms. To get a clear idea on my problem, here is my code. Please if some one could help me getting my problem solved. Thank you. <?php require_once('Connections/binary_data.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO binary_data (description, bin_data, filesize) VALUES (%s, %s, %s)", GetSQLValueString($_POST['description'], "text"), GetSQLValueString($_POST['bin_data'], "text"), GetSQLValueString($_POST['filesize'], "text")); mysql_select_db($database_binary_data, $binary_data); $Result1 = mysql_query($insertSQL, $binary_data) or die(mysql_error());

« previous php.webmaster (#2878) next »