ddevitt Posted July 25, 2006 Share Posted July 25, 2006 Hello everyone,I'm having a problem uploading a image file to the server and adding the filename to my MySQL database. I do not get any error messages, but in the database field the file name and path gets inserted. Example C:\images\test.jpg and still no uploaded file. my code is below. thanks in advance.[code]function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""){$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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")) {$var = $_FILES['propertyImg'] ['name'];move_uploaded_file ($_FILES['propertyImg'] ['tmp_name'],"../propimages/{$_FILES['propertyImg'] ['name']}");$insertSQL = sprintf("INSERT INTO offerings (pname, address, city, `state`, sqft, clearHeight, typeConstruction, additionalInfo, propertyImg, confientiality, memo, otherTitle1, otherFile1, otherTitle2, otherFile2, otherTitle3, otherFile3, otherTitle4, otherFile4, `user`, pass, displayOffering, buyer, seller, saleDate, mdesc, transSum, displayCaseStudy) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",GetSQLValueString($_POST['pName'], "text"),GetSQLValueString($_POST['address'], "text"),GetSQLValueString($_POST['city'], "text"),GetSQLValueString($_POST['state'], "text"),GetSQLValueString($_POST['sqft'], "text"),GetSQLValueString($_POST['clearHeight'], "text"),GetSQLValueString($_POST['typeConstruction'], "text"),GetSQLValueString($_POST['additionalInfo'], "text"),GetSQLValueString($_POST['propertyImg'], "text"),GetSQLValueString($_POST['confientiality'], "text"),GetSQLValueString($_POST['memo'], "text"),GetSQLValueString($_POST['otherTitle1'], "text"),GetSQLValueString($_POST['otherFile1'], "text"),GetSQLValueString($_POST['otherTitle2'], "text"),GetSQLValueString($_POST['otherFile2'], "text"),GetSQLValueString($_POST['otherTitle3'], "text"),GetSQLValueString($_POST['otherFile3'], "text"),GetSQLValueString($_POST['otherTitle4'], "text"),GetSQLValueString($_POST['otherFile4'], "text"),GetSQLValueString($_POST['user'], "text"),GetSQLValueString($_POST['pass'], "text"),GetSQLValueString(isset($_POST['displayOffering']) ? "true" : "", "defined","1","0"),GetSQLValueString($_POST['buyer'], "text"),GetSQLValueString($_POST['seller'], "text"),GetSQLValueString($_POST['saleDate'], "date"),GetSQLValueString($_POST['mdesc'], "text"),GetSQLValueString($_POST['transSum'], "text"),GetSQLValueString(isset($_POST['displayCaseStudy']) ? "true" : "", "defined","1","0"));mysql_select_db($database_converse, $converse);$Result1 = mysql_query($insertSQL, $converse) or die(mysql_error());$insertGoTo = "offeringsStart.php";if (isset($_SERVER['QUERY_STRING'])) {$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";$insertGoTo .= $_SERVER['QUERY_STRING'];}header(sprintf("Location: %s", $insertGoTo));}[/code] Link to comment https://forums.phpfreaks.com/topic/15594-file-upload-problem/ Share on other sites More sharing options...
PHPSpirit Posted July 25, 2006 Share Posted July 25, 2006 Use this to see the information of your file: print_r($_FILES);Maybe you can find the problem or perhaps you do not have permission to write in the directory. Link to comment https://forums.phpfreaks.com/topic/15594-file-upload-problem/#findComment-63489 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 try absolute path in move_uploaded_file Link to comment https://forums.phpfreaks.com/topic/15594-file-upload-problem/#findComment-63542 Share on other sites More sharing options...
fine Posted July 25, 2006 Share Posted July 25, 2006 I use this [url=http://www.kidslovepc.com/php-tutorial/php-insert-binary-mysql.shtml][b][u]PHP insert binary file into mysql example to insert my PDF file.[/u] [/b] [/url] there is no problem. Compare your code with the above link. Link to comment https://forums.phpfreaks.com/topic/15594-file-upload-problem/#findComment-63548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.