php.de

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

 
 
LinkBack Themen-Optionen Thema bewerten
Alt 10.03.2006, 22:07  
Gast
 
Beiträge: n/a
Standard Uploadscript geht nicht

Hallo.
Ich habe mir ein Uploadscript runtergeladen,aber es funktioniert nicht.Nach dem Upload kommt: Log:
Couldn't copy image 1 to server.Hier ist der PHP code.Ich hoffe ihr könnt mir auch sagen was falsch angegeben ist.Das Verzeichnis soll /Upload/ sein.

Code:
<?

// Original script developed by the Zach White Network.
// Modifications for flexible multi-uploads developed by
// Greg Johnson
// gjohnson@7south.com
// 7 South Communications, Inc.
// www.7south.com
// Mod Date: 11-07-02


//user defined variables
$abpath = "/Upload/"; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no"; //Do you want size limit, yes or no
$size = "1000000"; //What do you want size limited to be if there is one
$number_of_uploads = 1;  //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 $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=upload.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>
 
Sponsor Mitteilung
PHP Code Flüsterer

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

Alt 10.03.2006, 22:13  
Erfahrener Benutzer
 
Registriert seit: 02.04.2008
Beiträge: 2.603
Corvin befindet sich auf einem aufstrebenden Ast
Standard

Der Befehl
PHP-Code:
<?php
copy
($img[$i], "$abpath/$img_name[$i]")
?>
schlug fehl.
Wahrscheinlich hast du die Schreibrechte für den Ordner "Upload" nicht gesetzt.
Corvin ist offline  
Alt 10.03.2006, 23:21  
Gast
 
Beiträge: n/a
Standard

Hi
Erstmal danke für deine Antwort.Die Schreibrechte im Ordner Upload ist auf 777 gesetzt.Also kann es nicht daran liegen.
 
Alt 10.03.2006, 23:54  
Gast
 
Beiträge: n/a
Standard

Hallo,

$abpath = "/Upload/";
ein absoluter path sieht aber eher so aus
/server/usr/www/public_html/upload/

mit echo phpinfo(); die Variable heisst DOCUMENT ROOT
oder man könnte es mit
$abpath=$_SERVER["DOCUMENT_ROOT"].$abpath;
versuchen,, besser ist jedoch die direkte Eingabe des absoluten Verzeichnisses.
 
Alt 14.03.2006, 22:43  
Neuer Benutzer
 
Registriert seit: 29.05.2005
Beiträge: 9
blik
Standard Re: Uploadscript geht nicht

Zitat:
Zitat von Xittex
Hallo.
Ich habe mir ein Uploadscript runtergeladen,aber es funktioniert nicht.Nach dem Upload kommt: Log:
Couldn't copy image 1 to server.Hier ist der PHP code.Ich hoffe ihr könnt mir auch sagen was falsch angegeben ist.Das Verzeichnis soll /Upload/ sein.

Code:
//user defined variables
$abpath = "/Upload/"; //Absolute path to where images are uploaded. No trailing slash
Hmmm,
zumindest auf meinem XAMPP localhost funktioniert es - wenn ich die Anweisung "No trailing slash" beachte. :wink:

-> probier mal
Code:
$abpath = "Upload/";
, also ohne das führende "/"

Gruß
Blik
blik ist offline  
 


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
uploadscript SteiniKeule Beitragsarchiv 7 14.05.2008 23:12
Neues Problem mit uploadscript wiegia086 PHP Tipps 2006 5 28.03.2006 10:21
Brauche einige Tipps zu meinem Uploadscript PHP Tipps 2006 8 11.03.2006 22:42
uploadscript - was ist da falsch? imported_kremser PHP Tipps 2006 9 13.02.2006 19:43
Uploadscript - tmp_name immer leer trotz Auswahl PHP Tipps 2005-2 5 25.10.2005 13:18
Simples Uploadscript.. PHP Tipps 2005-2 14 09.09.2005 23:17
Uploadscript PHP Tipps 2005-2 4 24.08.2005 21:15
Uploadscript Beitragsarchiv 2 05.07.2005 15:40
Uploadscript? PHP Tipps 2005 2 10.04.2005 19:25
Intervallgesteuertes Uploadscript PHP-Fortgeschrittene 9 05.03.2005 19:19
Fehler beim Uploadscript PHP Tipps 2005 3 05.03.2005 11:27
Uploadscript aber wie? PHP Tipps 2005 1 13.02.2005 16:57
Problem mit Uploadscript PHP Tipps 2004-2 3 17.12.2004 21:58
uploadscript PHP Tipps 2004-2 0 09.12.2004 12:14
uploadscript mit unbestimmter anzahl von möglichen uploads PHP Tipps 2004 2 26.08.2004 14:56

Besucher kamen über folgende Suchanfragen bei Google auf diese Seite
$abpath = $_server[\document_root\];, png geht nicht upload script, upload-script funktioniert nicht, upload file php geht nicht, $abpath = $_server[\document_root\], input file nicht leer php, uploaded.to upload mit root geht net, $cert17 = \image/x-xwindowdump\; //xwd type

Alle Zeitangaben in WEZ +2. Es ist jetzt 12:14 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.