Hallo
ich möchte mir nicht allzu grosse Mühe machen und ein paar Nerven und Zeit sparen, deshalb suche ich ein solches Script.
Es soll FTP Upload können, in ein festes Verzeichnis. Gleichzeit soll es noch die Grösse der hoch(zu/ge)ladenen Datei zurückgeben.
Es kann( muss aber nicht) noch eine Msg ausgeben "die datei blabla.jpg wurde upgeloadet ;)"
beim hochladen soll darauf geachtet werden dass nur jpg's und gif & bmp's erlaubt ist....
Danke Euch !
snoova
:rolleyes:
Hallo,
wie wäre es denn hiermit?
In $file_name steht der Dateiname zum upload.
<?
$updir = "../upload"; //path to where files are uploaded
$sizelim = "no"; //do you want size limitations yes or no
$size = "25000"; //if you want size limited how many bytes
$certtype = "no"; //do you want certain type of file, no recommended
$type = ""; //what type of file would you like
//error if no file is selected
if ($file_name == "") { die("No file selected to upload"); }
//error if file exists
/* if (file_exists("$updir/$file_name")) { die("The file you are trying to upload already exists"); } */
//error if file is to big
if ($sizelim == "yes") {
if ($file_size > $size) { die("The file you are trying to upload is too big."); }
}
//error if file isn't certain type
if ($certtype == "yes") {
if ($type != $file_type) { die("The file you are trying to upload is wrong type"); }
}
//upload
@copy($file, "$updir/$file_name") or die("The file you are trying to upload couldn't be copied to the server");
?>
<html>
<head>
<title>File Uploaded</title>
</head>
<body>
<p>
<h2>File Uploaded</h2>
File Name: <? echo "$file_name"; ?><br>
File Size: <? echo "$file_size"; ?><br>
File Type: <? echo "$file_type"; ?>
</p>
</body>
</html>
FTP-Upload mit dem Browser geht nicht (Braucht nen FTP-Client).
@pekka :
geht nicht ?!
und was macht das script ?? geht es wirklich nur mit FTp_client ?
habe leider keine Chance zu testen, da ich nicht @home bin.
danke
snoova
Hi
Wolfi dein script bringt bei mir immer folgende Fehlermeldung :
"The file you are trying to upload couldn't be copied to the server"
warum ?!
@pekka:
FTP-Upload mit dem Browser geht definitiv !
@pekka:
FTP-Upload mit dem Browser geht definitiv !
Nein, das ist Dateiupload nach RFC 1234irgendwas, kein FTP. Nur der Definition halber, bringt einen sonst erstmal durcheinander :)
@moderatoren :
könntet ihr das hier verschieben ?! oder soll ich einen neuen Thread aufmachen :
@wolfi
ich habe mir jetzt nochmal die Variablen ausgeben lassen
das kommt raus.
die Datei sollte eine test.txt sein !
Datei: C:\\Dokumente und Einstellungen\\asdwq\\Desktop\\test.txt
Grösse:
TyP :
The file you are trying to upload couldn't be copied to the server
Bitte helft mir !
hier die code-erweiterung (auswahl der datei usw) :
-> sieht nicht grade toll aus, soll aber erstmal funzen
<?
if ($action!="send")
{
?>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form
action="test.php?action=send"
method="post">
<input name="file_name" type="file" >
<input type="submit" value="und los..." >
</body>
</html>
<?
}
if ($action=="send")
{
echo "Datei: $file_name";
echo "Grösse: $file_size";
echo "TyP :$type";
$updir = "../test"; //path to where files are uploaded
$sizelim = "no"; //do you want size limitations yes or no
$size = "25000000"; //if you want size limited how many bytes
$certtype = "no"; //do you want certain type of file, no recommended
$type = ""; //what type of file would you like
//error if no file is selected
if ($file_name == "") { die("No file selected to upload"); }
//error if file exists
/* if (file_exists("$updir/$file_name")) { die("The file you are trying to upload already exists"); } */
//error if file is to big
if ($sizelim == "yes") {
if ($file_size > $size) { die("The file you are trying to upload is too big."); }
}
//error if file isn't certain type
if ($certtype == "yes") {
if ($type != $file_type) { die("The file you are trying to upload is wrong type"); }
}
//upload
@copy($file, "$updir/$file_name") or die("The file you are trying to upload couldn't be copied to the server");
?>
<html>
<head>
<title>File Uploaded</title>
</head>
<body>
<p>
<h2>File Uploaded</h2>
File Name: <? echo "$file_name"; ?><br>
File Size: <? echo "$file_size"; ?><br>
File Type: <? echo "$file_type"; ?>
</p>
</body>
</html>
<?
}
?>
Danke für eure Hilfe !
snoova
Hallo snoova,
bei mir läuft dieses Script definitiv. Selbst auf unterschiedlichen
Linux-Systemen.
Habe das Script heute aber mal unter Windows bei mir zu Hause getestet und ich bekomme dei gleiche Meldung. Werde mich mal daran setzen woran dies liegt.
Aber mit den FTP-Befehlen die Php unterstützt geht es auf jeden Fall. Da habe ich auch ein Script.
Gruß
Wolfi
Hallo snoova,
du musst im HTML mit enctype="multipart/form-data" arbeiten
Beispiel: HTML
<form method="POST" action="http://127.0.0.1/htmlphp/upload.php3" enctype="multipart/form-data">
<input type=file name=file size=30>
<input id=input type="hidden" name="task" value="upload"><br><br>
<INPUT TYPE="SUBMIT" NAME="eingabe" VALUE="upload"></form>
Beispiel PHP
$updir = "../upload"; //Ist der relative Pfad zu HTDOCS
Absolut: C:/Programme/Apache/htdocs/upload
Damit sollte es eigentlich gehen. Bei Problemen einfach mailen.
Mfg
Wolfi