AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Uploadtool coden, wie geht das mit der IdHTTP Componente?
Thema durchsuchen
Ansicht
Themen-Optionen

Uploadtool coden, wie geht das mit der IdHTTP Componente?

Offene Frage von "0NyX"
Ein Thema von 0NyX · begonnen am 16. Okt 2007 · letzter Beitrag vom 20. Okt 2007
 
Benutzerbild von 0NyX
0NyX

Registriert seit: 13. Aug 2007
67 Beiträge
 
#1

Uploadtool coden, wie geht das mit der IdHTTP Componente?

  Alt 16. Okt 2007, 17:56
Guten Abend liebe DP User,

ich habe mal wieder ein Problem

Und zwar geht es sich um folgendes:
Ich will für meinen kleinen FIleHoster (nach mehrfachem Wunsch der User) ein Uploadtool schreiben.
Bisher ging es auch gut voran, nur jetzt beim wichtigstem komme ich nicht weiter und zwar beim Upload.
Ich würde mich riesig freuen wenn ihr mir ein bisschen Helfen könntet.

Hier der bisherige Delphi Code [auch im Anhang]:

Delphi-Quellcode:
unit UT;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    LbDateien: TListBox;
    BtAddFile: TButton;
    BtDeletFile: TButton;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    GroupBox2: TGroupBox;
    StaticText1: TStaticText;
    LblSpeed: TLabel;
    ProgressBar1: TProgressBar;
    GroupBox3: TGroupBox;
    MemLinks: TMemo;
    IdHTTP1: TIdHTTP;
    procedure BtAddFileClick(Sender: TObject);
    procedure BtDeletFileClick(Sender: TObject);
    procedure IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
      AWorkCount: Integer);
  private
    { Private-Deklarationen }
  public
  anzahl_listbox:integer;
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BtAddFileClick(Sender: TObject);
begin
  opendialog1.Execute;
  anzahl_listbox := LbDateien.Items.Count;
  LbDateien.Items[anzahl_listbox] := opendialog1.FileName;
  anzahl_listbox := LbDateien.Items.Count;
end;

procedure TForm1.BtDeletFileClick(Sender: TObject);
begin
  LbDateien.DeleteSelected;
end;

procedure TForm1.IdHTTP1Work(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCount: Integer);
Var
  S: String;
  TotalTime: TDateTime;
  H, M, Sec, MS: Word;
  DLTime: Double;
  STime: TDateTime;
  AverageSpeed: Double;
begin
  ProgressBar1.Max := AWorkCount;
  ProgressBar1.Position := 0;
Application.ProcessMessages;
  TotalTime := Now - STime;
  DecodeTime(TotalTime, H, M, Sec, MS);
  Sec := Sec + M * 60 + H * 3600;
  DLTime := Sec + MS / 1000;
  if DLTime > 0 then
    AverageSpeed := (AWorkCount / 1024) / DLTime;
  S := FormatFloat('0.00 KB/s', AverageSpeed);
  case AWorkMode of
       wmWrite : LblSpeed.Caption := 'Uploade speed ' + S;
  end;
  ProgressBar1.Position := AWorkCount;
  Form1.ProgressBar1.Refresh;
end;

end.


Und hier noch meine upload.php:

Delphi-Quellcode:
<?php
include("./config.php");
include("./header.php");
include("./lang/$language.php");

$junk = array('.' , ',' , '/' , '\\' , '`' , ';' , '[' , ']' , '-', "'", '*', '&', '^', '%', '$', '@', '!', '~', '+', '(', ')', '|', '{', '}', ' ', '?', ':', '"', '=', "<", ">", " &");
$multi = array(
'__', '___', '____', '_____', '______');

$filename = $_FILES[
'upfile']['name'];
$filename = str_replace("
'",'',"$filename");
$filename = str_replace("&",'',"$filename");
$filename = stripslashes("$filename");
$filesize = $_FILES['upfile']['size'];
$fancyurl=rand('1','999');
$rand2=("$fancyurl$filename");

$m=$shourturl;
if ($m=="true")
  $short= "";
else
  $short= "download.php?file=";

$bans=file("./secure/bans.mfh");
foreach($bans as $line)
{
  if ($line==$rand2."\n"){
?> <center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
<?
    echo "$lang[noallow]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
  }

  if ($line==$_SERVER['REMOTE_ADDR']."\n"){
?><center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
  <? echo "$lang[nallow]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
  }

}

if(isset($allowedtypes)){
$allowed = 0;
foreach($allowedtypes as $ext) {
  if(substr($filename, (0 - (strlen($ext)+1) )) == ".".$ext)
    $allowed = 1;
}

if($allowed==0) {
?><center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  echo "$lang[itype]";
  ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
include("./footer.php");
  die();
}

}

if(isset($categorylist)){
$validcat = 0;
foreach($categories as $cat) {
  if($_POST['category']==$cat || $_POST['category'] = ""){ $validcat = 1; }

}
if($validcat==0) {
?><center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
  echo "$lang[icat]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
  include("./footer.php");
  die();
}

$cat = $_POST['category'];
} else { $cat = ""; }

if($filesize==0) {
?><center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
echo "$lang[dpick]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
include("./footer.php");
die();
}


$filesize = $filesize / 1048576;

if($filesize > $maxfilesize) {
?><center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
echo "$lang[tlarge]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
include("./footer.php");
die();
}


$userip = $_SERVER['REMOTE_ADDR'];
$time = time();

if($filesize > $nolimitsize)
{
$newfile = "./uploader/".$userip.".mfh";
$f=fopen($newfile, "w");
fwrite ($f,$userip."|".$time."|");
fclose($f);
chmod($newfile,0777);
}


$passkey = rand(100000, 999999);

if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
$uploadmsg = "$lang[ufile] (".$filename.") $lang[wup].\n  ". $lang[udownfile] . ":" . $scripturl . "$short" . $rand2 . "\n ". $lang[udeletefile] . ":" . $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . "\n $lang[thank]";
mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: ". $email ."\n");
}


if($passwordoption && isset($_POST['pprotect'])) {
  $passwerd = md5($_POST['pprotect']);
}
 else { $passwerd = md5(""); }

if($descriptionoption && isset($_POST['descr'])) {
  $description = strip_tags($_POST['descr']);
}
 else { $description = ""; }

$filelist = fopen("./files/".$rand2.".mfh","w");
fwrite($filelist, $rand2 ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|\n");

$movefile = "./storage/" . $rand2;
move_uploaded_file($_FILES['upfile']['tmp_name'], $movefile);
?>
<center><table style="margin-top:0px;width:741px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>


<?
include("./ads.php");
echo "<center>[b]Ihre Datei wurde erfolgreich hochgeladen!
[/b]


</center>";
echo "<center>[b]Download Link:
[/b]</br> <textarea name='textarea' cols='65' wrap='soft' rows='1'>". $scripturl . "$short" . $rand2 . "</textarea>

</center>";
echo "<center>[b]BB Code:
[/b]
<textarea name='textarea' cols='65' wrap='soft' rows='2'>[url=". $scripturl . "" . $rand2 . "]$compname Download Link[/url]</textarea>

</center>";
echo "<center>[b]HTML Code:
[/b]
<textarea name='textarea' cols='65' wrap='soft' rows='2'>[url=". $scripturl . "]$compname Download Link[/url]</textarea>

</center>";
echo "<center>[b]Um die Datei zu löschen nutzen Sie folgenden Link:
[/b] </br><textarea name='textarea' cols='65' wrap='soft' rows='2'>" . $scripturl . "download.php?file=" . $rand2 . "&del=" . $passkey . "</textarea>

</center>";
echo "<center>[b]Bitte merken Sie sich diese Links![/b]</center>";
?>



<?
include("./bottomads.php");
?>
  </td></tr></table></center>
<?

include("./footer.php");
?>
VIELEN DANK IM VORAUS!
Angehängte Dateien
Dateityp: rar uploadtool_105.rar (270,4 KB, 7x aufgerufen)
"Der Computer rechnet mit allem, nur nicht mit seinem Nutzer!"
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:21 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz