Hello,
I'm trying to upload images into a folder "uplaod" and saving their location in MySql database. I have the code - the broplem is that have many additional fields and I'm using the "editFormAction" script. How can I make both of them to work together?
Currently when I see the page online - it says immediately "invalid file"...
Thanks for your help!
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formInsertSale")) {
$insertSQL = sprintf("INSERT INTO neve_sale (aptType, area, address, built, lot, BR, floor, floorAll, parking, elevator, price, available, available1, status, details, myDetails, pic1, descpic1, pic2, descpic2, pic3, descpic3, pic4, descpic4, pic5, descpic5) 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)",
GetSQLValueString($_POST['aptType'], "text"),
GetSQLValueString($_POST['area'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['built'], "int"),
GetSQLValueString($_POST['lot'], "int"),
GetSQLValueString($_POST['BR'], "int"),
GetSQLValueString($_POST['floor'], "int"),
GetSQLValueString($_POST['floorAll'], "int"),
GetSQLValueString($_POST['parking'], "text"),
GetSQLValueString($_POST['elevator'], "text"),
GetSQLValueString($_POST['price'], "int"),
GetSQLValueString($_POST['available'], "text"),
GetSQLValueString($_POST['available1'], "text"),
GetSQLValueString($_POST['status'], "text"),
GetSQLValueString($_POST['details'], "text"),
GetSQLValueString($_POST['myDetails'], "text"),
GetSQLValueString($_POST['pic1'], "text"),
GetSQLValueString($_POST['descPic1'], "text"),
GetSQLValueString($_POST['pic2'], "text"),
GetSQLValueString($_POST['descPic2'], "text"),
GetSQLValueString($_POST['pic3'], "text"),
GetSQLValueString($_POST['descPic3'], "text"),
GetSQLValueString($_POST['pic4'], "text"),
GetSQLValueString($_POST['descPic4'], "text"),
GetSQLValueString($_POST['pic5'], "text"),
GetSQLValueString($_POST['descPic5'], "text"));
mysql_select_db($database_connection1, $connection1);
$Result1 = mysql_query($insertSQL, $connection1) or die(mysql_error());
$insertGoTo = "admin-sales1.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_connection1, $connection1);
$query_Recordset1 = "SELECT * FROM neve_sale";
$Recordset1 = mysql_query($query_Recordset1, $connection1) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
upload pictures and saving location in MySql database PHP -together with other fields
Started by PHPbeginner, May 23 2011 01:52 AM
1 reply to this topic
#1
Posted 23 May 2011 - 01:52 AM
|
|
|
#2
Posted 23 May 2011 - 02:02 PM
please use the code tags to format your code.
to find whats wrong with your image upload do the following:
-make sure the form tag with the file input has the method post and has enctype="multipart/form-data"
-inspect what the form sends to your php script to see if your file is uploaded to server by using
to find whats wrong with your image upload do the following:
-make sure the form tag with the file input has the method post and has enctype="multipart/form-data"
-inspect what the form sends to your php script to see if your file is uploaded to server by using
var_dump($_POST);
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









