Warnung: file_put_contents(/home/www/web1/html/php_dev/test.txt) [function.file-put-contents]: failed to open stream: Permission denied in /home/www/web1/html/php_dev/sys/lib.activity.php (Zeile 58)
[S] FTP Upload Script [Archiv] - PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr

- Ad -
php-resource




Archiv verlassen und diese Seite im Standarddesign anzeigen :
[S] FTP Upload Script


 
snoova
16-05-2002, 13:36 
 
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:

 
Wolfi
16-05-2002, 15:56 
 
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>

 
pekka
16-05-2002, 16:32 
 
FTP-Upload mit dem Browser geht nicht (Braucht nen FTP-Client).

 
snoova
16-05-2002, 16:35 
 
@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

 
snoova
03-06-2002, 16:08 
 
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
03-06-2002, 16:22 
 
@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 :)

 
snoova
03-06-2002, 16:42 
 
@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

 
Wolfi
03-06-2002, 19:26 
 
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

 
Wolfi
03-06-2002, 20:23 
 
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

- -

Alle Zeitangaben in WEZ +2. Es ist jetzt 18:11 Uhr.