Hab mal wieder eine nette kleine Herausforderung für euch: Mein kleines Upload-Script will irgendwie nicht so richtig.
Hab mir ein relativ simples Script gebaut wo man alle Datei-Endungen der Welt hochladen kann und man auch nicht auf die Größe schauen muss. ABER irgendwie bekomm ich immer den Fehler dass er eine Variabel nicht lesen kann, was aber nicht so richtig sein kann.
Schaut selbst:
Jetzt bekomm ich dauernd die Fehlermeldung: copy(): Unable to access in /www/htdocs/public/scripts/upload/index2.php on line 42
Wobei Zeile 42 hier diese wäre:
Nur hab ich jetzt grad keine Ahnung was da falsch ist...
Nur zu Info. Es wird am Anfang des Scripts die Datei "config.php" includiert, in dieser Datei ist lediglich mein Passwort und der Upload-Order gespeichert.
Das wär das eine, und nur so nebenbei, gibt es eine PHP Funktion mit der mir der Syntax einer .PHP/.HTML/-Datei farbig angezeigt werden kann?
THANKS!
A2k
--
The problem with America is stupidity.
I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?
----
Arguing with the moderators is like shaking your fist at God. There's nobody there; and if there is, he's not listening. And if he's listening, all you're doing is pissing him off.
Auch für Dateiuploads gibt es ein Superglobales Array: $_FILES!
Im PHP Manual findest du dazu besondere Informationen im Kapitel Dateiuploads mit POST
Bearbeitung:
Variablen verkettest du mit dem Punkt:
Außerdem bin ich mir nicht sicher, ob du bei copy nicht den absoluten Pfad angeben musst.
Eventuell interessiert dich auch die Funktion move_uploaded_file().
...
Ich muss zugeben, dass übersteigt meine PHP-Kenntnisse mal wieder
Hab jetzt mal die Zeile 42 editiert und in meinen $upload_folder mit absoluter Adressenangabe ausgestattet, will aber trotzdem nicht.
Da er mir immer noch den selben Fehler anzeigt hab ich leider auch keine Ahnung inwiefern ich das jetzt was ändern könnte... PHP-N00b eben
Also so einfach wie ich mir das ganze vorstelle funktioniert ein Dateiupload also nicht, richtig?
Großartig
--
The problem with America is stupidity.
I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?
----
Arguing with the moderators is like shaking your fist at God. There's nobody there; and if there is, he's not listening. And if he's listening, all you're doing is pissing him off.
Wenn du ein Inputfeld hast, welches den Namen 'file' trägt und es sich dabei um eine Eingeabefeld für Dateien handelt stehen dir nach dem absenden diese Variablen zur Verfügung:
move_uploaded_file() kopiert dir dann die temporär angelegte Datei in das gewünschte Verzeichnis.
Stell dir das vor wie in Windows: beim Entpacken von komprimierten Dateien kopiert das System zuerst alles in ein temporäres Verzeichnis, erst wenn alles entpackt ist wird alles in das gewünschte Verzeichnis kopiert. So läuft das hier auch.
Der Pfad muss dem denein nur angepasst werden.
Bearbeitung:
Das offensichtlicher habe ich wieder übersehen :/
Du musst das Verzeichnis, in welches du die Dateien kopieren möchtest mit Schreibrechten versehen.
D.h. in deinem FTP Programm den Ordner auswählen. Du müsstest dann irgendwo in der Lage sein, "Attribute" oder CHMOD zu bearbeiten. Es wird der Wert 777 benötigt (Lesen, Schreiben und Ausführen für alle).
Beachte bitte auch, dass du keine Datei hochladen kannst, die größer ist als upload_max_filesize in der PHP.ini
Sorry, aber ich krieg das nicht hin. Ich bekomm nachdem ich auf Upload drücke (die Datei wird auch upgeloadet) immer diese Fehlermeldung:
Warning: move_uploaded_file(/www/www/virtual/armitage2k.net/htdocs/public/scripts/upload/up/): failed to open stream: Is a directory in /www/www/virtual/armitage2k.net/htdocs/public/scripts/upload/index.php on line 50
Warning: move_uploaded_file(): Unable to move '/www/www/virtual/armitage2k.net/phptmp/php0fYkNz' to '/www/www/virtual/armitage2k.net/htdocs/public/scripts/upload/up/' in /www/www/virtual/armitage2k.net/htdocs/public/scripts/upload/index.php on line 50
Also am besten ich poste mal meine gesamte Source damit ihr seht was ich eigentlich gebastelt hab. Sorry, aber PHP ist definitiv nicht meine Stärke, fang grad erst an damit effizient zu basteln.
config.php
Der gesamte Ordner inkl. Dateien hat CHMOD 777, trotzdem will es nicht so richtig funktionieren.
Danke für die Hilfe,
A2k
--
The problem with America is stupidity.
I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?
----
Arguing with the moderators is like shaking your fist at God. There's nobody there; and if there is, he's not listening. And if he's listening, all you're doing is pissing him off.
Ich glaub es liegt ean einem simlen Tippfehler meinerseits ; ;
Ach ja, die $_FILES Variablen sind automatisch gegeben, wenn was hochlädst, du musst sie also nicht selbst erstellen.
Der Tippfehler war, dass ich bei move_uploaded_file() die Angabe vom Manual übernommen hatte, ohne sie anzupassen.
Hab jetzt mal die geänderte Zeile eingefügt und die Variablen gelöscht. Jetzt bekomm ich zwar keine Fehlermeldung mehr, aber er will mir trotzdem keine Datei in das gewünschte Verzeichnis laden....
Gott, es kann doch nicht sein dass ein so simpler Dateiupload derartige Probleme macht....
Trotzdem vielen lieben Dank für die ganze Hilfe!
A2k
Hier nochmal die aktuelle Source:
--
The problem with America is stupidity.
I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?
----
Arguing with the moderators is like shaking your fist at God. There's nobody there; and if there is, he's not listening. And if he's listening, all you're doing is pissing him off.
Ich habe das Script jetzt mal auf meiem PC getestet.
Bei der gelegenheit: Bitte immer <?php schreiben, das ist die einzige PHP Kennung die immer funktioneirt
Das Script hat funktioniert.
Ich denke ser Fehler liegt in der Pfadangabe:
Die Form passt. Die Angabe hatte ich bei mir aber falsch, da ein Verzeichnis falsch geschrieben war, was in einer leeren Seite resultierte.
Überprüf also den Pfad ggf. mit phpinfo() und korrigiere ihn. Eine andere Fehlerquelle kann es nicht geben.
Jo, Script läuft jetzt endlich, allerdings nicht auf der Seite wo es eigentlich hin soll
Hab das Script jetzt rein interessehalber mal auf meinem PHP5 Host laufen lassen und da funktioniert es einwandfrei. Kann es sein dass event. bestimmte Befehle im Script auf dem Host meiner eigentlichen Website nicht erkannt werden (PHP4 --> phpinfo())?
Danke nochmals für die ganze Hilfe!
A2k
--
The problem with America is stupidity.
I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?
----
Arguing with the moderators is like shaking your fist at God. There's nobody there; and if there is, he's not listening. And if he's listening, all you're doing is pissing him off.
Hm, ich habe zwar hier auch PHP 5, aber wir verwenden keine Funktionen die es in deiner PHP 4 Version nicht auch gibt.
Ich weis auch nicht, was error_reporting(2039); genau bedeutet, eventuell fügst du error_reporting(E_ALL); über deinem Script ein, vielleicht gibt dir das Script dann eine zusätzliche Warnung aus.
Ansonnsten sehe ich nicht, wo das Problem liegen könnte, Dateiuploads sind bei dir aktiviert usw.
Interessant. Auf meinem PHP5 Server gehts reibungslos. Auf meinem PHP4 Server hab ich jetzt mal auf alle Fehler anzeigen und bekomm da die Meldung dass 2 Variablen undefiniert sind. Das Script ist aber 1:1 dasselbe wie auf dem PHP5 Server....?
Hier mal die Fehlermeldung:
Notice: Undefined index: upload in /www/www/virtual/armitage2k.net/htdocs/public/scripts/upload/uploader.php on line 22
Notice: Undefined index: file in /www/www/virtual/armitage2k.net/htdocs/public/scripts/upload/uploader.php on line 23
Dabei gehts um die Variablen $status und $dateiname:
Naja, wenn niemanden mehr einfällt was da los ist, ist es auch egal. Aber nochmal vielen herzlichen Dank für die ganze Hilfe!
A2k
--
The problem with America is stupidity.
I'm not saying there should be a capital punishment for stupidity, but why don't we just take the safety labels off of everything and let the problem solve itself?
----
Arguing with the moderators is like shaking your fist at God. There's nobody there; and if there is, he's not listening. And if he's listening, all you're doing is pissing him off.