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.

PHP - variable aus dem nichts?

Empfohlene Antworten

Veröffentlicht

Hallo Ihr Coder :)

ich brauch dringend eure hilfe!

Ich habe folgenden Quelltext:

<?PHP

if(!empty($file_name)){

if(@copy($file,"tmp/$file_name"))

{

echo "<b>Upload beendet!</b><br>";

echo "Dateiname: $file_name";

echo "<br>";

echo "Dateigröße: $file_size Byte"; }

}

else

{

?>

<html><head></head><body bgcolor="#FFFFFF" text="#000000"><form name="form1" enctype="multipart/form-data" method="post" action="index.php"><p> <input type="file" name="file"><br><input type="submit" name="Abschicken" value="Download beginnen"></p></form></body></html>

<?PHP

}

?>

Der Quellcode stammt von selfphp und funktioniert garantiert.

Es handelt sich dabei um eine einfache Fileupload funktion.

Wie zum Henker wird hier der Dateiname $file_name und die Dateigröße $file_size gesetzt?

Die Daten werden korrekt ausgegeben, aber woher kommen die?

Danke für eure Hilfe!

Jan

da dein das "name" - Attribut aus deinem input feld (typ='file') den namen "file" trägt,

wir automatisch eine varibale namens file_name bzw file_size gesetzt

du könntest auch das superglobale array $_FILE verwenden

Well so far none of the suggestions mentioned here has worked for me. I am currently using the following pieced together from all the different comments and continue to get an "attack" error. The file I am unloading is 4Bytes and I have the MAX-SIZE set to 100000. Here is the code:

<?

print "$userfile = userfile

";

print "$userfile_name = userfile_name

";

print "$userfile_type = userfile_type

";

print "$userfile_size = userfile_size

";

print "$tmp_name = tmp_name

";

// In PHP 4.1.0 or later, $_FILES should be used instead of $HTTP_POST_FILES.

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

copy($HTTP_POST_FILES['userfile']['tmp_name'], "f:\\place\\to\\file\\");

} else {

echo "Possible file upload attack: filename '".$HTTP_POST_FILES['userfile']['name'].".";

}

/* ...or... */

move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], "f:\\place\\to\\file\\");

?>

Here is the result:

= userfile

test.txt = userfile_name

text/plain = userfile_type

= userfile_size

= tmp_name

Possible file upload attack: filename 'test.txt.

Hi,

die Werte generiert php automatisch aus dem File Upload Stream!

Dein Beispiel ist übrigens sehr alt und sollte so nicht mehr verwendet werden.

So ist es besser! ;)

11.11. Wie funktioniert ein Datei-Upload über HTML-Formulare?

http://www.dclp-faq.de/q/q-formular-upload-php4.html

Gruß Jaraz

Verschoben -> Webserverprogrammierung

Danke für die ersten antworten!

Jetzt tritt leider ein folgeproblem auf.

Also zum besseren verständiss: Ich muss das phpbb forum durch eine fileupload-funtkion erweitern.

Die Dateiauswahl durch <input ...> hab ich gemacht.

abgeschickt wird das ganze so:

<form action="{S_POST_ACTION}" method="post" name="post" onsubmit="return checkForm(this)">

Allerdings weiss ich jez nicht, wie ich die variablen $file_sizes und $file_name mit übergeben soll, weil nach meinen versuchen, kann ich die im verarbeitendem script nicht einfach aufrufen.

THX

im <form> tag fehlt noch

ENCTYPE="multipart/form-data"

Original geschrieben von Jaraz

Hi,

die Werte generiert php automatisch aus dem File Upload Stream!

Dein Beispiel ist übrigens sehr alt und sollte so nicht mehr verwendet werden.

So ist es besser! ;)

11.11. Wie funktioniert ein Datei-Upload über HTML-Formulare?

http://www.dclp-faq.de/q/q-formular-upload-php4.html

Gruß Jaraz

Vielen Dank für eure Hilfe! Das Problem ist gelößt!

Im Eifer des gefechts und meiner unerfahrenheit hab ich vergessen die Variablen im funktionsaufruf zu übergeben 00000095.gif

Keine Sorge ich hab bald noch mehr fragen *g*

Original geschrieben von Hamshire

Keine Sorge ich hab bald noch mehr fragen *g*

solange es weiter nichts ist :marine

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.