Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Uploadscript

Empfohlene Antworten

Veröffentlicht

Hi Leute,

Bin gerade dabei einen Uploadscript zu basteln aber irgendwie komm ich nicht weiter..

Hier der Code


<html>

<body>

<h4>Uplo4d Script by RUM-St1FT</h4>

<form enctype="multipart/form-data" action="upload.php" method="post">

<h>Datei:    </h><input type="file" name="file"><br>

<h>Passwort: </h><input type="password" name="pw"><br>

<br><input type="submit" value="Upload it!">

</form>

</body>

</html>


<?php

opendir("/upload");

$datei = $_POST["file"];

$pw = "lool";

if(!empty($_POST["file"]))

{

echo "Es wurde keine Datei zum Upload angegeben !!";

}

if(file_exists($datei))

{

echo "Die Datei existiert bereits auf dem Server !!";

}

if($_POST["pw"] == $pw)

{

copy($_POST["file"],"upload/$datei");

echo "Upload erfolgreich";

}

else

{

echo "Passwort nicht korrekt! Bitte nochmal versuchen <br>";

echo "Bitte geben sie eine Datei fuer den Upload an !!";

}

?>

[/code]

Als Ausgabe erfolgt "Upload erfolgreich" aber es landet nix im Verzeichniss.

Das Verzeichniss hat 777 Rechte.

Was ist da falsch ?

Danke für eure Hilfe

Mfg

Feigling

Probier mal, ob etwas in

$_FILES['file']['tmp_name']

(anstatt $_POST["file"])

drinsteht, das ist normalerweise die Datei an sich

wieso verwendest du nicht die für uploads mit PHP vorgesehenen funktionen (move_uploaded_file, is_uploaded_file, etc.)?

if($_POST["pw"] == $pw)
{
copy($_POST["file"],"upload/$datei");
echo "Upload erfolgreich";
}[/PHP]

übrigens: du wendest "copy" an, und egal ob der vorgang erfolgreich war oder nicht, gibst du "Upload erfolgreich" an. das ist absoluter blödsinn. weiters

[PHP]if(file_exists($datei))

hier überprüfst du, ob eine datei im aktuellen scriptverzeichnis existiert, aber nicht, ob bereits dieselbe zuvor upgeloadet wurde.

sieh dir mal PHP: Steuerung von Dateiuploads - Manual an.

s'Amstel

Folgende Ausgabe


Es wurde keine Datei zum Upload angegeben !!Upload erfolgreich

Mfg

Feigling

Folgende Ausgabe


Es wurde keine Datei zum Upload angegeben !!Upload erfolgreich

Mfg

Feigling

kommt von der Zeile

if(!empty($_POST["file"]))

{

echo "Es wurde keine Datei zum Upload angegeben !!";

}

Wenn $_POST["file"] NICHT "empty" ist dann gib die Meldung aus. Und da Du was für $_POST["file"] ausgewählt hast, ist das nicht "empty"

Scau Dir mal das hier an:

PHP: move_uploaded_file - Manual

Dein Uploadscript ist nicht gerade "günstig" gemacht... ;)

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.