![]() |
Re: [CGI] Zeile an Datei anhängen
Hi,
hier das Buch "Perl für Win32" ... der einzige Unterscheid sind eben die Pfade aber das sollte sich schnell in den Griff bekommen lassen ... ![]() ![]() Kosten beide 9,95? + 3,00? !!! Also alles in allem nen Top - Angebot ... Neupreis 30,** ?. Ich hab mir gestern schon eins bestellt ... |
Re: [CGI] Zeile an Datei anhängen
Dank eines Tipps aus dem Spotlight, geht es jetzt:
Code:
Es haben noch die ">>" bei open gefehlt.
#!/usr/bin/perl -w
use strict; use CGI; # Modul fuer CGI-Programme use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; # neues Objekt erstellen # die datei-daten holen my $file = $cgi->param("myfile"); my $dir = $cgi->param("dir"); my $comment = $cgi->param("comment"); # Content-type fuer die Ausgabe # print $cgi->header(-type => 'text/html'); # dateinamen erstellen und die datei auf dem server speichern my $fullpath = $cgi->param("myfile"); my $index = rindex($fullpath, "\\"); my $filename = substr($fullpath, ($index + 1)); my $fname = '../'.$dir.'/'.$filename; open DAT,'>'.$fname or die 'Error processing file: ',$!; # Dateien in den Binaer-Modus schalten binmode $file; binmode DAT; my $data; while(read $file,$data,1024) { print DAT $data; } close DAT; my $haccessfile = '../'.$dir.'/.htaccess'; my $newline = 'AddDescription "'.$comment.'" '.$filename; open(FILE, "[b]>>[/b]$haccessfile") || die 'Cannot locate database file: '. $haccessfile.'!'; print FILE "\n$newline"; close(FILE); print "Content-Type: text/html\n\n"; print "<head><title>Homepage von Michael Puff - Datei-Uploadbestätigung</title></head>"; print "<html><body>"; print "<h1>Datei-Uploadbestätigung</h1>"; print "<hr>"; print $haccessfile." "; print $newline." "; print "Datei [b]".$filename."[/b] erfolgreich nach [b]http://www.luckie-online.de/".$dir."/[/b] hochgeladen. "; print "<a href=\"http://www.luckie-online.de/sitemanager\">Zurück</a>"; print "</body></html>"; |
Re: [CGI] Zeile an Datei anhängen
Zitat:
Konntest Du etwas zum Locking in Erfahrung bringen? Kann es zB Probleme geben, wenn zwei Prozesser mit Deinem Script die Datei verändern oä? |
Re: [CGI] Zeile an Datei anhängen
Nein. Aber das ist bei mir nicht von Interesse, wenn zwei Prozesse das Script ausführen, dann habe ich ganz andere Probleme als die Konsistenz der Datei. :zwinker:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:05 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz