
Z uploadem na serwer sobie poradzę, bo już to robiłem.
Skrypt potrzebuje do strony na zaliczenie na studia, jestem słaby z php, korzystam z Dreamweawera więc to co widzicie poniżej wygenerował program:
Kod
<?php require_once('Connections/oferty.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"] == "upload")) {
$insertSQL = sprintf("INSERT INTO of_oferty (foto) VALUES (%s)",
GetSQLValueString($_POST['userfile'], "text"));
mysql_select_db($database_oferty, $oferty);
$Result1 = mysql_query($insertSQL, $oferty) or die(mysql_error());
}
mysql_select_db($database_oferty, $oferty);
$query_zdjecia = "SELECT foto FROM of_oferty";
$zdjecia = mysql_query($query_zdjecia, $oferty) or die(mysql_error());
$row_zdjecia = mysql_fetch_assoc($zdjecia);
$totalRows_zdjecia = mysql_num_rows($zdjecia);
?>
<form action="<?php echo $editFormAction; ?>" name="upload" id="upload" ENCTYPE="multipart/form-data" method="POST">
<input type="file" id="userfile" name="userfile">
<input type="submit" name="upload" value="Upload">
<input type="hidden" name="MM_insert" value="upload" />
</form>
<?php
mysql_free_result($zdjecia);
?>
<?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"] == "upload")) {
$insertSQL = sprintf("INSERT INTO of_oferty (foto) VALUES (%s)",
GetSQLValueString($_POST['userfile'], "text"));
mysql_select_db($database_oferty, $oferty);
$Result1 = mysql_query($insertSQL, $oferty) or die(mysql_error());
}
mysql_select_db($database_oferty, $oferty);
$query_zdjecia = "SELECT foto FROM of_oferty";
$zdjecia = mysql_query($query_zdjecia, $oferty) or die(mysql_error());
$row_zdjecia = mysql_fetch_assoc($zdjecia);
$totalRows_zdjecia = mysql_num_rows($zdjecia);
?>
<form action="<?php echo $editFormAction; ?>" name="upload" id="upload" ENCTYPE="multipart/form-data" method="POST">
<input type="file" id="userfile" name="userfile">
<input type="submit" name="upload" value="Upload">
<input type="hidden" name="MM_insert" value="upload" />
</form>
<?php
mysql_free_result($zdjecia);
?>
Tak poza tym to mój pierwszy post więc witam i pozdro dla wszystkich