php.de

Zurück   php.de > Webentwicklung > PHP Einsteiger > PHP Tipps 2004

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 10.08.2004, 14:15  
Gast
 
Beiträge: n/a
Standard Suche Hilfe um Uploadscript umzuschreiben

Hi!

Ich möchte bei folgendem Script die Ausgabe nach dem Upload so gestallten, das es entweder automatisch auf ein anderes Script weiterleitet und dabei die Namen der Bilder als Variable weitergibt bzw das man einem Link geziegt bekommt, der beim anklicken auf das andere Script verweist und die Variablen weitergibt.
Weiterleitung usw is ja kein Problem,
aber wie bekomme ich die BildNamen als Variable gesetzt?

Code:
<?

//user defined variables
$abpath = "/home/www/web168/html/images/mainimages/"; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no"; //Do you want size limit, yes or no
$size = "2500000"; //What do you want size limited to be if there is one
$number_of_uploads = 2;  //Number of uploads to occur

if ($_REQUEST['submitted']){ // Begin processing portion of script

//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
$cert4 = "image/ief"; //Ief type
$cert5 = "image/png"; //Png type
$cert6 = "image/tiff"; //Tiff type
$cert7 = "image/bmp"; //Bmp Type
$cert8 = "image/vnd.wap.wbmp"; //Wbmp type
$cert9 = "image/x-cmu-raster"; //Ras type
$cert10 = "image/x-x-portable-anymap"; //Pnm type
$cert11 = "image/x-portable-bitmap"; //Pbm type
$cert12 = "image/x-portable-graymap"; //Pgm type
$cert13 = "image/x-portable-pixmap"; //Ppm type
$cert14 = "image/x-rgb"; //Rgb type
$cert15 = "image/x-xbitmap"; //Xbm type
$cert16 = "image/x-xpixmap"; //Xpm type
$cert17 = "image/x-xwindowdump"; //Xwd type

$log = "";

for ($i=0; $i<$number_of_uploads; $i++) {

	//checks if file exists
	if ($img_name[$i] == "") {
		$log .= "No file selected for upload $i
";
	}

	if ($img_name[$i] != "") {
		//checks if file exists
		if (file_exists("$abpath/$img_name[$i]")) {
			$log .= "File $i already existed
";
		} else {

			//checks if files to big
			if (($sizelim == "yes") && ($img_size[$i] > $size)) {
				$log .= "File $i was too big
";
			} else {


				//Checks if file is an image
				if (($img_type[$i] == $cert1) or ($img_type[$i] == $cert2) or ($img_type[$i] == $cert3) or ($img_type[$i] == $cert4) or ($img_type[$i] == $cert5) or ($img_type[$i] == $cert6) or ($img_type[$i] == $cert7) or ($img_type[$i] == $cert8) or ($img_type[$i] == $cert9) or ($img_type[$i] == $cert10) or ($img_type[$i] == $cert11) or ($img_type[$i] == $cert12) or ($img_type[$i] == $cert13) or ($img_type[$i] == $cert14) or ($img_type[$i] == $cert15) or ($img_type[$i] == $cert16) or ($img_type[$i] == $cert17)) {
					@copy($img[$i], "$abpath/$img_name[$i]") or $log .= "Couldn't copy image 1 to server
";
					if (file_exists("$abpath/$img_name[$i]")) {
						$log .= "File $img_name[$i] was uploaded
";
					}
					} else {
						$log .= "File $i is not an image
";
					}
				}
			}
		}


	}

?>

<html>
<head>
<title>Image Report</title>
</head>
<body>


Log:

<?

echo "$log";

?>
</p>
<body>
</html>
<? 
exit;
} // End processing portion of script
?>

<html>
<head>
<title>Upload Image</title>
</head>
<body>
<form method=POST action=uploadmulti.php enctype=multipart/form-data>


Files to upload:

<? 

for ($j=0; $j<$number_of_uploads; $j++) {
?>
<input type=file name=img[] size=30>

<?
}
?>
<input type="hidden" name="submitted" value="true">
<input type="submit" name="submit" value="Upload"> 
</form>
</body>
</html>
Ich hab mit meinem bisschen PHP-Kenntniss leider keinen Erfolg erzielen können.
Weiß von Euch evtl. jemand wie ich das anstellen kann?

Viele Grüße

Andreas
 
Sponsor Mitteilung
PHP Code Flüsterer

Registriert seit: 21.08.2005
Beiträge: 4682
PHP-Kenntnisse:
Fortgeschritten

Alt 10.08.2004, 16:29  
Erfahrener Benutzer
 
Registriert seit: 21.05.2008
Beiträge: 2.150
Guradia befindet sich auf einem aufstrebenden Ast
Standard Re: Suche Hilfe um Uploadscript umzuschreiben

Zitat:
Zitat von fur
Ich möchte bei folgendem Script die Ausgabe nach dem Upload so gestallten, das es entweder automatisch auf ein anderes Script weiterleitet und dabei die Namen der Bilder als Variable weitergibt bzw das man einem Link geziegt bekommt, der beim anklicken auf das andere Script verweist und die Variablen weitergibt.
Der Zweck ist jetzt nicht so wirklich erkennbar ...

Zitat:
Zitat von fur
Weiterleitung usw is ja kein Problem,
aber wie bekomme ich die BildNamen als Variable gesetzt?
Nunja .. da das Script insgesamt reichlich suspekt ist ... wurdert mich das nicht wikrlich ..

Hiermit allerdings, kannst du dir einen sinnvollenen Ansatz anschauen, wo du die Namen herholen kannst:

PHP-Code:
<?php
print '<pre>';
var_dump($_FILES);
print 
'</pre>';
?>

Und die Weiterleitung sollte evtl. so aussehen: ?
?uppedPic[]=foo.jpg&uppedPic[]=bar.gif
Was dann in etwas resultieren sollte, dass du dir so anschauen kannst:
PHP-Code:
<?php
print '<pre>';
var_dump($_REQEUST['uppedPic']);
print 
'</pre>';
?>
Guradia ist offline  
Alt 10.08.2004, 16:29  
Erfahrener Benutzer
 
Registriert seit: 14.12.2003
Beiträge: 211
pit62
Standard $img_name

Hy ists das wass Du suchst
<script language=\"JavaScript\">
window.open('datei.php?bildname=$img_name'); /neue seite
window.location.href('datei.php??bildname=$img_nam e'> // weiterleitung auf andere Seite
</script>

Mfg Pit62
pit62 ist offline  
Alt 10.08.2004, 17:04  
Gast
 
Beiträge: n/a
Standard

Hi Guradia

Du sagst, es sieht sehr suspekt aus...
darum hier noch mal mein eigentliches Problem.
Evtl denk ich auch nur zu kompliziert...

Ich habe ein Script, welches Daten in eine MySQL Datenbank einpflegt.
Da ich bei zwei Eingabe-Feldern aber gerne einen Bildupload gesetzt hätte, welcher die Dateien in ein vorgegebenes Verzeichniss läd und den Bild-Namen in die Datenbank einträgt, dass aber weder alleine geschafft habe noch durch die Hilfe hier im Forum großartig weiter gekommen bin, dachte ich mir,
Uploadscript für mehrere Dateinen genommen und die Ausgabe so wie beschrieben umgeändert.
Dann bei dem Datenbank-Script einfach die Variablen als Value der besagten Eingabefelder gesetzt und schon hätte ich damit ja indirekt das,
was ich erreichen möchte.

Kann sein, das ich da evtl. auf Grund meiner mangelden PHP-Kenntnisse da einfach zu starr denke.

Hast Du evtl. ein gutes, einfaches Script um mehrere Bild-Dateien hochzuladen, was weniger suspekt programmiert ist?


@ pit62

ist´s nicht ganz :wink:
aber trotzdem vielen Dank.


Viele Grüße

Andreas
 
 


Themen-Optionen
Thema bewerten
Thema bewerten:

Forumregeln
Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are an
Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Ich suche Hilfe bei einem Problem mit Navicat Chris1234 PHP Tipps 2008 1 09.02.2008 09:41
Auf der Suche nach hilfe... PHP Tipps 2007 11 11.12.2005 03:09
[Erledigt] suche hilfe bei bbcodes PHP-Fortgeschrittene 0 05.08.2005 16:10
[Erledigt] suche hilfe bei bbcodes PHP-Fortgeschrittene 0 05.08.2005 16:10
Suche Hilfe... :) Beitragsarchiv 1 19.07.2005 13:09
suche php-formular und hilfe Beitragsarchiv 3 18.05.2005 15:28
Suche Hilfe beim erstellen eines Browsergames! Beitragsarchiv 13 18.04.2005 23:59
Suche Hilfe zur Zeitmessung PHP Tipps 2005 5 18.04.2005 09:09
phpBB 2.0.13 GEHACKT !!!! Suche professionelle Hilfe..... Beitragsarchiv 6 01.04.2005 22:22
[Erledigt] suche hilfe: html-body extrahieren und urls kürzen! PHP-Fortgeschrittene 9 07.03.2005 14:58
Suche Hilfe PHP Tipps 2005 4 28.02.2005 08:11
Suche -dringend- Hilfe zu einem Smily Mod! <- HiLFE - :-) PHP Tipps 2004-2 0 07.11.2004 13:50
Hilfe suche Web Mail PHP Tipps 2004 1 27.06.2004 18:58

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
upload script automatisch, hilfe bei upload script, if ($img_name[$i] == \\)

Alle Zeitangaben in WEZ +2. Es ist jetzt 05:41 Uhr.




Powered by vBulletin® Version 3.7.2 (Deutsch)
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Aprilia-Forum, Aquaristik-Forum, Liebeskummer-Forum, Zierfisch-Forum, Geizkragen-Forum

Creative Commons License
Dieser Inhalt ist unter einer Creative Commons-Lizenz lizenziert.