Shop Support News Archive - Shopbetreiber News -> Forum : $_get[problem]
hi,
ich hab ein uploadscript, dem will ich eine variable übergeben. es liegt alles in einem php script.
hier der befehl wo die variable übergeben wird...
echo "<a href=\"gallery.php?gallery=$file\"><img width=\"100\" src=\"../images/gallery/$file/$file.gif\"></a>
die variable übergeb ich so...
gallery.php?gallery=$file
ein paar zeilen später kommt mein uploadscript
hier fang ich die variable gallery auf und zwar mit dem befehl...
$dateiname = $_GET[gallery];
zusammen mit dem uploadscript sieht das dann so aus:
<?
if($action_admineng1){
$dateiname = $_GET[gallery];
$filename = "";
$time=time();
if ($HTTP_POST_FILES['userfile']['tmp_name']<> 'none'){
$file = $HTTP_POST_FILES['userfile']['name'];
$temp = $HTTP_POST_FILES['userfile']['tmp_name'];
$path_parts = pathinfo($file);
$filename = "$file";
$dest = $path."../images/gallery/$dateiname1/".$filename;
copy($temp, $dest);
echo '<font size=1>Datei ist auf den Server!
</font>';
echo '<font size=2>Url der Datei: '.$deindomain.$path.$filename.'</font>
zurück zum upload (gallery.php)';
}
} else {
?>
<form method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="400000">
<table><tr>
<td><input name="userfile" type="file" size=30></td>
<td><input type="submit" name="action_admineng1" value="Speichern"></td>
</form>
<? } ?>
leider wird &dateiname1 nicht erkannt:-( weis einer warum nicht?
ich glaub ich hab den get befehl nicht rnichtig eingebunden, mehr weis ich aber auch nicht
hoff einer von euch kann mir helfen
gruß
1. Bleib bei $dateiname oer bei $dateiname1
2. Versuche es mal mit $_GET['gallery']; //Anführungszeichen
''>ZITAT(c(oyo)p @ Aug 26 2007, 21:23) 31712
1. Bleib bei $dateiname oer bei $dateiname1
2. Versuche es mal mit $_GET['gallery']; //Anführungszeichen
[/b]
habs grad ausprobiert, klappt aber leider nicht, hättest du noch ne idee?
Ich korrigier dir mal ein paar kleine Fehler
echo '../images/gallery/'. $file .'/'. $file .'.gif (gallery.php?gallery='. $file .')';
die variable übergeb ich so...
gallery.php?gallery=$file
ein paar zeilen später kommt mein uploadscript
hier fang ich die variable gallery auf und zwar mit dem befehl...
$dateiname = $_GET[gallery];
zusammen mit dem uploadscript sieht das dann so aus:
<?
if($action_admineng1){
****$dateiname = $_GET['gallery'];
****$filename = "";
****$time=time();
****if ($HTTP_POST_FILES['userfile']['tmp_name'] <> 'none'){**
********$file = $HTTP_POST_FILES['userfile']['name'];
********$temp = $HTTP_POST_FILES['userfile']['tmp_name'];
********$path_parts = pathinfo($file);
********$filename = $file;
********$dest = $path ."../images/gallery/$dateiname1/". $filename;
********copy($temp, $dest);
********echo '<font size=1>Datei ist auf den Server!
</font>
****************<font size=2>Url der Datei: '. $deindomain . $path . $filename .'</font>
zurück zum upload (gallery.php)';
****}
} else {
?>
****<form method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>">
****<input type="hidden" name="MAX_FILE_SIZE" value="400000">
****<table><tr>****
****<td><input name="userfile" type="file" size=30></td>
****<td><input type="submit" name="action_admineng1" value="Speichern"></td>
****</form>
<? } ?>
Anführungszeichen im $_GET vergessen.
was soll das < > in der if bedingung?
!= wäre hier angebrachter
hm es will nicht hinhauen...
als ich den befehl geändert habe hat der die variable file nicht mehr gehabt
echo '../images/gallery/'. $file .'/'. $file .'.gif (gallery.php?gallery='. $file .')';
hier nochmal das ganze script, vielenicht ist der fehler auch woanders...
ach ja kann auch gut son anführungszeichen fehler sein, da ich bis heute keinen editor benutze kommen da von hand schnell fehler rein:-(
hier das komplette script:
<?php
/ -----------------------------------------------------------------------------------------
shoutbox.php
XT-Commerce - community made shopping
http://www.xt-commerce.com (http://anonym.to/?http://www.xt-commerce.com)
Copyright © 2003 XT-Commerce
-----------------------------------------------------------------------------------------
based on:
© 2000-2001 The Exchange Project (earlier name of osCommerce)
© 2002-2003 osCommerce (account.php,v 1.59 2003/05/19); www.oscommerce.com
© 2003 nextcommerce (account.php,v 1.12 2003/08/17); www.nextcommerce.org
Released under the GNU General Public License
--------------------------------------------------------------
Third Party contribution:
Ajax-Shoutbox: © Thorsten Reineke, 2006, http://www.get-attention.de (http://anonym.to/?http://www.get-attention.de)
Released under the GNU General Public License
-------------------------------------------------------------- /
require('includes/application_top.php');
require(DIR_FS_INC. 'xtc_remove_non_numeric.inc.php');
if ($_POST['maxrows']){
$maxrows = xtc_remove_non_numeric(xtc_db_prepare_input($_POST['maxrows']));
} else {
$maxrows = $_GET['maxrows'];
}
if ($maxrows <= '20') $maxrows=20;
if ($_GET['clear_id']){
xtc_db_query("delete from " . TABLE_SHOUTBOX . " where shoutbox_id ='".$_GET['clear_id']."'");
}
if ($_GET['clear_all']=='true'){
xtc_db_query("truncate " . TABLE_SHOUTBOX);
}
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Tranistional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
</table></td>
<td class="boxCenter" width="100%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" width="100%" cellspacing="5" cellpadding="5">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="80" rowspan="2"><?php echo xtc_image(DIR_WS_ICONS.'heading_customers.gif'); ?></td>
<td class="pageHeading">Gallery Manager v1.0</td>
</tr>
<tr>
<td class="main" valign="top">XT Modul by Label23.com (www.Label23.com (http://www.Label23.com))</td>
</tr></table><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="main" valign="top">
</td>
</tr>
<tr>
<td class="main" valign="top" colspan="3">
<Table cellspacing="5" cellpadding="5" bgcolor="#e1e1e1" border="0">
<tr><td>
<table>
<tr>
<td>
<script type="text/javascript">
function anzeigen(das){
if(document.getElementById(das).style.display=='no ne')
document.getElementById(das).style.display='block' ;
else document.getElementById(das).style.display='none'; }
</script>
HILFEEIN / AUS (#)
WICHTIGE HINWEISE:
</td></tr></table>
<table>
<tr>
<td>
<font size="1">NEUE GALLERY ERSTELLEN:</font>
<font size="1">
<?
if($action_gallery){
$filename = "";
$time=time();
if ($HTTP_POST_FILES['userfile']['tmp_name']<> 'none'){
$file = $HTTP_POST_FILES['userfile']['name'];
$temp = $HTTP_POST_FILES['userfile']['tmp_name'];
$path_parts = pathinfo($file);
$filename = "$name.gif";
$directory = "../images/gallery/$name";if(!file_exists($directory)) if(!@mkdir($directory)) echo "fehler beim erstellen des verzeichnisses!";
$dest = $path."../images/gallery/$name/".$filename;
copy($temp, $dest);
echo '<font size=1>Datei ist auf den Server!
</font>';
echo '<font size=2>Url der Datei: '.$deindomain.$path.$filename.'</font>
zurück zum upload (gallery.php)';
}
} else {
?>
<form method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="400000">
<table><tr><td><input name="name" type="text" size=30></td>
<td><input name="userfile" type="file" size=30></td>
<td><input type="submit" name="action_gallery" value="Speichern"></td>
</form>
<? } ?>
</td></tr></table>
<tr>
</tr>
</span>
</td></tr></table>
<div><font size=1>GALLERY ÜBERSICHT:</font>
<?
$ordner = "../images/gallery/";
$handle = opendir($ordner);
while ($file = readdir ($handle)) {
if($file != "." && $file != "..") echo "<a href=\"gallery.php?galleryx=$file\"><img width=\"100\" src=\"../images/gallery/$file/$file.gif\"></a>
<font size=2><a href=\"gallery.php?gallery=$file\">EDIT $file</a></font>
";
}
closedir($handle);
?>
</div>
<table width="100%">
<tr>
<td width="100%" bgcolor="#c9c9c9" cellspacing=5 cellpadding=5>
</tr>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="main" valign="top">
</td>
</tr>
<tr>
<td class="main" valign="top" width="100%">
<table cellspacing="5" cellpadding="5" height=100% valign="top" width="100%">
<tr>
<td valign="top" class="main">
<?
if($action_admineng1){
$dateiname1 = $_GET['galleryx'];
$filename = "";
$time=time();
if ($HTTP_POST_FILES['userfile']['tmp_name'] <> 'none'){
$file = $HTTP_POST_FILES['userfile']['name'];
$temp = $HTTP_POST_FILES['userfile']['tmp_name'];
$path_parts = pathinfo($file);
$filename = "$file";
$dest = $path ."../images/gallery/$dateiname1/". $filename;
copy($temp, $dest);
echo '<font size=1>Datei ist auf den Server!
</font>
<font size=2>Url der Datei: '. $deindomain . $path . $filename .'</font>
zurück zum upload (gallery.php)';
}
} else {
?>
<form method="post" enctype="multipart/form-data" action="<?php echo $PHP_SELF ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="400000">
<table><tr>
<td><input name="userfile" type="file" size=30></td>
<td><input type="submit" name="action_admineng1" value="Speichern"></td>
</form>
<? } ?>
<?
$dateiname1 = $_GET['galleryx'];
$ordner = "../images/gallery/$dateiname1/";
$handle = opendir($ordner);
while ($file = readdir ($handle)) {
/ Nur Bilder auslesen - bzw. gewünschte Dateitypen festlegen /
$sub = substr($file, -4);
if ($sub == ".png" || $sub == ".jpg" || $sub == ".gif" || $sub == ".bmp")
{
if($file != "." && $file != "..") {
if(is_dir($ordner."/".$file)) {
echo "/".$file."
";
} else {
echo "<tr>";
echo "<td><img src='$ordner/$file' width='100'></td>";
echo "<td class=\"main\">$file</td>";
echo "<td class=\"main\">löschen? ('../images/gallery/gallery1$BilderOrdner/bild.del.php?del=$file')</td>"; // Löschen mit Bestätigung
echo "</tr>";
}
}}
}
closedir($handle);
?>
</td>
</tr>
</table>
</td></tr>
</table>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
''>ZITAT(Alucard @ Aug 26 2007, 22:06) 31719
Fehlermeldungen?
[/b]
also mit dem script so wie ichs jetzt grad hocgestellt hab kommen keine fehlermeldungen, der speichert das bild auch ab, nur nicht an die rnichtige stelle, er ignoriert die &dateiname1.
kanns daran liegen das vorher schon ein upload befehl steht? das erste script soll das nämlich genau an die stelle speichern
nicht das sich beide uploadscripte schwierigkeiten machen.
bin mit meinem latein echt am ende, kann jetzt nur noch raten worann es liegen kann:-(
ich hab jetzt mal das upload lef um 1 eingabe feld erweitert wo man von hand das ziel eingeben muß, bei der variante gehts.... komisch.
könnte ich das evt über eine select feld lösen?
wie kann ich einen ordner auslesen und den inhalt als auswahlbox darstellen?
langsam fällt mir wirklich nix mehr ein:-(
lockdron
29.08.2007, 14:00
Wenn ich das ganze rnichtig interpretiere (und davon gehe ich gerne aus ^^),
dann hast du erst deine Seite mit dem Link. Wenn du auf den klickst, kommst du zu deiner Upload-Form und übergibst mit Hilfe von dem Link die URL. Anwalt Hamm
Wenn soweit falsch ist, brauchst du garnicht mehr weiterlesen ; )
Überprüf mal, ob du nach absenden der Datei noch die "rnichtige" URL mit Variablen an der URL in der Adressleiste hast. Hab zwar grad nicht die möglichkeit zum testen, aber meines Wissens nach zeigt PHP_SELF nur auf die momentane Datei. D.h. deine $_GET-Variable geht "verloren". Und wenn ich das rnichtig verstanden hab, klappts ja, wenn du in deinen Dateiupload ein Eingabefeld einbaust.
Mein Vorschlag:
Versuch mal, die $_GET-Variable auszugeben. Beim Aufruf von der Form sollte sie da sein, nach dem Absenden nicht mehr. Wenn das zutrifft, kannst du die Variable in die Form reinschreiben, indem du einfach ein "hidden" Feld benutzt.<input type="hidde" name="DEINE_VARIABLE" value="HIER_GET_VARIABLE_AUSGEBEN" />
Hoffe das war verständlich und hilfe.
by lockdron
''>ZITAT(lockdron @ Aug 29 2007, 14:00) 31805
... indem du einfach ein "hidden" Feld benutzt.<input type="hidde" name="DEINE_VARIABLE" value="HIER_GET_VARIABLE_AUSGEBEN" />
[/b]
Du solltest dann aber auch das rnichtige Beispielcode angeben type="hidden":
<input type="hidden" name="DEINE_VARIABLE" value="HIER_GET_VARIABLE_AUSGEBEN" />
Insbesondere weiß man nie ob da nicht irgendwelche Sonderzeichen drin sind in so ner Variable, erzeugen solcher rückgabe-Verte also immer mit htmlentities ausgeben. Enthält $file z.B. folgendes $file='J&J Soft' sind deine Links hinüber:
aus echo "<a href=\"gallery.php?gallery=$file\"><img width=\"100\" src=\"../images/gallery/$file/$file.gif\"></a>"; wird dann
../images/gallery/J&J Soft/J&J Soft.gif (gallery.php?gallery=J&J Soft)Hier wird $gallery=J übergeben, es gibt dafür nen zweiten parameter ohne Wert (J), je nach browser auch "J Soft".
nutze statt dessen:
echo '../images/gallery/'.htmlentities($file).'/'.htmlentities($file).'.gif (gallery.php?gallery='.htmlentities($file).)';
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.