Jump to content


Photo

file upload problem


  • Please log in to reply
3 replies to this topic

#1 ddevitt

ddevitt
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 25 July 2006 - 03:26 PM

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.
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));
}


#2 PHPSpirit

PHPSpirit
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 25 July 2006 - 04:56 PM



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.



#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 06:08 PM

try absolute path in move_uploaded_file
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#4 fine

fine
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 July 2006 - 06:34 PM

I use this PHP insert binary file into mysql example to insert my PDF file.

there is no problem. Compare your code with the above link.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users