Viktor1982
Grünschnabel
Hallo,
ich habe es soweit geschaft das die Datei hochgeladen wird!
Was muss ich hinzufügen das die datei in die datenbank Tabelle: "address_book", Feld: "Bild" eingetragen wird und zusätzlich zu customers_id auch noch die adressbuch id als dateiname gespeichrt wird? Also derzeit ist es so:
customers_id_dateiname.jpg
und so will ich es:
customers_id_address_book_id_dateiname.jpg
**************
Formular:
*************
<td align="center" class="main" colspan="0">
<script TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function upload(){
window.open('upload.php', '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizeble=no, width=300, height=200');
return;
}
// -->
</SCRIPT>
<A HREF="JavaScript:upload();"><IMG SRC="images/icons/upload.gif"></A>
</td>
</TR>
******************
upload.php:
*****************
<?php
/*
upload.php file upload for logo files
Donnerstag 5.2.2004 09:11
*/
require('includes/application_top.php');
if (!tep_session_is_registered('customer_id')) {
echo "Upload not allowed!";
exit;
}
require(DIR_WS_LANGUAGES . $language . '/upload.php');
$max_size=2220480;
$upload_path='/home/www/htdocs/upload/';
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo UPLOAD_TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="5" bottommargin="0" leftmargin="5" rightmargin="5">
<?php
echo '<p class="main">';
printf(UPLOAD_TEXT,$max_size);
if(!isset($HTTP_POST_FILES['toProcess'])){
//Formular anzeigen
?>
<FORM enctype="multipart/form-data" action="<?php
$PHP_SELF; ?>" method="POST">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size;?>">
<TABLE border="0" cellspacing="0" cellpadding="5">
<TR class="infoBox">
<TD class="infoBoxContents"><?php echo UPLOAD_FILE_NAME;?></TD>
<TD class="infoBoxContents"><input name="toProcess" type="file"></TD>
</TR>
<TR class="infoBox"><TD class="infoBoxContents" colspan="2" align="center"><input type="submit" value="Upload"></TD></TR>
</TABLE>
</FORM>
<?php
}else{
$file = tep_get_uploaded_file('toProcess');
$ok= eregi('(.*\.gif$|.*\.jpg$)',$file['name']);
if ($ok && is_uploaded_file($file['tmp_name']) && $file['size']< $max_size) {
$rec_query=tep_db_query('select * from ' . TABLE_ADDRESS_BOOK . ' where customers_id='.(int)$customer_id);
$rec= tep_db_fetch_array($rec_query);
$new_file=$upload_path.$customer_id.'_'.$file['name'];
move_uploaded_file($file['tmp_name'],$new_file);
$rc=exec('chmod 0660 '.$new_file);
echo '<BR><BR>'.UPLOAD_SUCCESS;
}else{
echo '<BR><BR>'.UPLOAD_ERROR;
}
}
?>
</p>
</BODY>
</HTML>
DANKE
ich habe es soweit geschaft das die Datei hochgeladen wird!
Was muss ich hinzufügen das die datei in die datenbank Tabelle: "address_book", Feld: "Bild" eingetragen wird und zusätzlich zu customers_id auch noch die adressbuch id als dateiname gespeichrt wird? Also derzeit ist es so:
customers_id_dateiname.jpg
und so will ich es:
customers_id_address_book_id_dateiname.jpg
**************
Formular:
*************
<td align="center" class="main" colspan="0">
<script TYPE="text/javascript" LANGUAGE="JavaScript">
<!--
function upload(){
window.open('upload.php', '_blank', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizeble=no, width=300, height=200');
return;
}
// -->
</SCRIPT>
<A HREF="JavaScript:upload();"><IMG SRC="images/icons/upload.gif"></A>
</td>
</TR>
******************
upload.php:
*****************
<?php
/*
upload.php file upload for logo files
Donnerstag 5.2.2004 09:11
*/
require('includes/application_top.php');
if (!tep_session_is_registered('customer_id')) {
echo "Upload not allowed!";
exit;
}
require(DIR_WS_LANGUAGES . $language . '/upload.php');
$max_size=2220480;
$upload_path='/home/www/htdocs/upload/';
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo UPLOAD_TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="5" bottommargin="0" leftmargin="5" rightmargin="5">
<?php
echo '<p class="main">';
printf(UPLOAD_TEXT,$max_size);
if(!isset($HTTP_POST_FILES['toProcess'])){
//Formular anzeigen
?>
<FORM enctype="multipart/form-data" action="<?php
$PHP_SELF; ?>" method="POST">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size;?>">
<TABLE border="0" cellspacing="0" cellpadding="5">
<TR class="infoBox">
<TD class="infoBoxContents"><?php echo UPLOAD_FILE_NAME;?></TD>
<TD class="infoBoxContents"><input name="toProcess" type="file"></TD>
</TR>
<TR class="infoBox"><TD class="infoBoxContents" colspan="2" align="center"><input type="submit" value="Upload"></TD></TR>
</TABLE>
</FORM>
<?php
}else{
$file = tep_get_uploaded_file('toProcess');
$ok= eregi('(.*\.gif$|.*\.jpg$)',$file['name']);
if ($ok && is_uploaded_file($file['tmp_name']) && $file['size']< $max_size) {
$rec_query=tep_db_query('select * from ' . TABLE_ADDRESS_BOOK . ' where customers_id='.(int)$customer_id);
$rec= tep_db_fetch_array($rec_query);
$new_file=$upload_path.$customer_id.'_'.$file['name'];
move_uploaded_file($file['tmp_name'],$new_file);
$rc=exec('chmod 0660 '.$new_file);
echo '<BR><BR>'.UPLOAD_SUCCESS;
}else{
echo '<BR><BR>'.UPLOAD_ERROR;
}
}
?>
</p>
</BODY>
</HTML>
DANKE