Autor Beitrag
Cix6
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Do 12.01.06 17:32 
Hi,


ich möchte gerne ein Bild einlesen und an ein PHP Script übertragen, welches das Bild dann wieder speichert.


Wie kann ich das am besten machen?

kann ich das bild einfach in nen stringlist laden, dann als string an die php datei senden und dann von php als bild speichern lassen oder ist das ganze doch schwieriger?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Do 12.01.06 17:57 
Sorry, aber ich habe noch nie von einer Möglichkeit gehört, ein Bild in einer Stringlist zu speichern... :wink:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 12.01.06 18:20 
Moin!

user profile iconKoller hat folgendes geschrieben:
Sorry, aber ich habe noch nie von einer Möglichkeit gehört, ein Bild in einer Stringlist zu speichern... :wink:

Das geht schon, ein String ist in Delphi ja ein Speicherblock mit Länge (nicht wie in C nullterminiert, da ginge das nicht). Aber du hast schon Recht, darauf wird er wohl nicht abgezielt haben... :wink:

@user profile iconCix6: Schau dich mal zum Stichwort STREAMs um, das sollte dir weiterhelfen.

cu
Narses
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Do 12.01.06 18:45 
kann ich denn einem php script einen stream übertragen!
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Mo 16.01.06 16:26 
Du könntest den Stream in einer Datei abspeichrn und dann mit PHP auslesen.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Di 17.01.06 10:38 
und wie soll ich die datei auf den server bekommen? ftp etc ist nicht erlaubt!
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: So 22.01.06 23:32 
Du könntest es doch so gestalten das, das PHP Script die Datei hochläd.
Das wäre IMHO einfacher.
Der Pfad, wo die Datei liegt kannst du mit einem Trick per Parameter übergeben.
ausblenden Delphi-Quelltext
1:
urldownloadtofile(nil, 'http://www.bla.blub/muh.php?id=PFAD', 'C:\temp.txt', 0, nil);					

(Aus der Forensuche)
caedes
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 35

Win XP
Delphi 7 Enterprise, C
BeitragVerfasst: Mo 23.01.06 00:26 
Hab hier mal nen Link (www.dreamcodes.de/text/?id=409&s=read) zum Thema Dateiupload mit PHP. Du imitierst mit deinem Programm einfach einen POST, wie ihn das HTTP sonst auch macht und das PHP-Script nimmt das Ding entgegen und speichert es ab.
Mit
 $tmp_name = $HTTP_POST_FILES['bild']['tmp_name']; übernimmst du den Upload in eine Variable, mit der du weiterarbeiten kannst. Den HTML-Kram brauchst du natürlich nicht und auch den Button nicht.

Hab mit Ethereal nochmal den Uploadvorgang dokumentiert:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
0000  00 11 d8 97 e2 49 00 13  d4 d9 ae 25 08 00 45 00   .....I.. ...%..E.
0010  02 d1 18 37 40 00 80 06  ff 0f c0 a8 01 02 d5 b2   ...7@... ........
0020  49 83 04 b0 00 50 9c b4  d0 80 f0 97 a7 27 50 18   I....P.. .....'P.
0030  ff ff e3 a3 00 00 50 4f  53 54 20 2f 63 61 65 64   ......PO ST /caed
0040  65 73 2f 75 70 6c 6f 61  64 2e 70 68 70 20 48 54   es/uploa d.php HT
0050  54 50 2f 31 2e 31 0d 0a  48 6f 73 74 3a 20 77 77   TP/1.1.. Host: ww
0060  77 2e 6c 75 6d 69 6e 61  74 65 63 2e 64 65 0d 0a   w.lumina tec.de..
0070  55 73 65 72 2d 41 67 65  6e 74 3a 20 4d 6f 7a 69   User-Age nt: Mozi
0080  6c 6c 61 2f 35 2e 30 20  28 57 69 6e 64 6f 77 73   lla/5.0  (Windows
0090  3b 20 55 3b 20 57 69 6e  64 6f 77 73 20 4e 54 20   ; U; Win dows NT 
00a0  35 2e 31 3b 20 64 65 3b  20 72 76 3a 31 2e 38 29   5.1; de;  rv:1.8)
00b0  20 47 65 63 6b 6f 2f 32  30 30 35 31 31 31 31 20    Gecko/2 0051111 
00c0  46 69 72 65 66 6f 78 2f  31 2e 35 0d 0a 41 63 63   Firefox/ 1.5..Acc
00d0  65 70 74 3a 20 74 65 78  74 2f 78 6d 6c 2c 61 70   ept: tex t/xml,ap
00e0  70 6c 69 63 61 74 69 6f  6e 2f 78 6d 6c 2c 61 70   plicatio n/xml,ap
00f0  70 6c 69 63 61 74 69 6f  6e 2f 78 68 74 6d 6c 2b   plicatio n/xhtml+
0100  78 6d 6c 2c 74 65 78 74  2f 68 74 6d 6c 3b 71 3d   xml,text /html;q=
0110  30 2e 39 2c 74 65 78 74  2f 70 6c 61 69 6e 3b 71   0.9,text /plain;q
0120  3d 30 2e 38 2c 69 6d 61  67 65 2f 70 6e 67 2c 2a   =0.8,ima ge/png,*
0130  2f 2a 3b 71 3d 30 2e 35  0d 0a 41 63 63 65 70 74   /*;q=0.5 ..Accept
0140  2d 4c 61 6e 67 75 61 67  65 3a 20 64 65 2d 64 65   -Languag e: de-de
0150  2c 64 65 3b 71 3d 30 2e  38 2c 65 6e 2d 75 73 3b   ,de;q=0. 8,en-us;
0160  71 3d 30 2e 35 2c 65 6e  3b 71 3d 30 2e 33 0d 0a   q=0.5,en ;q=0.3..
0170  41 63 63 65 70 74 2d 45  6e 63 6f 64 69 6e 67 3a   Accept-E ncoding:
0180  20 67 7a 69 70 2c 64 65  66 6c 61 74 65 0d 0a 41    gzip,de flate..A
0190  63 63 65 70 74 2d 43 68  61 72 73 65 74 3a 20 49   ccept-Ch arset: I
01a0  53 4f 2d 38 38 35 39 2d  31 2c 75 74 66 2d 38 3b   SO-8859- 1,utf-8;
01b0  71 3d 30 2e 37 2c 2a 3b  71 3d 30 2e 37 0d 0a 4b   q=0.7,*; q=0.7..K
01c0  65 65 70 2d 41 6c 69 76  65 3a 20 33 30 30 0d 0a   eep-Aliv e: 300..
01d0  43 6f 6e 6e 65 63 74 69  6f 6e 3a 20 6b 65 65 70   Connecti on: keep
01e0  2d 61 6c 69 76 65 0d 0a  52 65 66 65 72 65 72 3a   -alive.. Referer:
01f0  20 68 74 74 70 3a 2f 2f  77 77 77 2e 6c 75 6d 69    http:// www.lumi
0200  6e 61 74 65 63 2e 64 65  2f 63 61 65 64 65 73 2f   natec.de /caedes/
0210  75 70 6c 6f 61 64 2e 70  68 70 0d 0a 43 6f 6f 6b   upload.p hp..

0000  00 11 d8 97 e2 49 00 13  d4 d9 ae 25 08 00 45 00   .....I.. ...%..E.
0010  05 c0 18 38 40 00 80 06  fc 1f c0 a8 01 02 d5 b2   ...8@... ........
0020  49 83 04 b0 00 50 9c b4  d3 29 f0 97 a7 27 50 18   I....P.. .)...'P.
0030  ff ff e6 92 00 00 43 6f  6e 74 65 6e 74 2d 54 79   ......Co ntent-Ty
0040  70 65 3a 20 6d 75 6c 74  69 70 61 72 74 2f 66 6f   pe: mult ipart/fo
0050  72 6d 2d 64 61 74 61 3b  20 62 6f 75 6e 64 61 72   rm-data;  boundar
0060  79 3d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d   y=------ --------
0070  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 34 31 31   -------- -----411
0080  38 34 36 37 36 33 33 34  0d 0a 43 6f 6e 74 65 6e   84676334 ..Conten
0090  74 2d 4c 65 6e 67 74 68  3a 20 33 35 31 31 0d 0a   t-Length : 3511..
00a0  0d 0a 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d   ..------ --------
00b0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 34   -------- -------4
00c0  31 31 38 34 36 37 36 33  33 34 0d 0a 43 6f 6e 74   11846763 34..Cont
00d0  65 6e 74 2d 44 69 73 70  6f 73 69 74 69 6f 6e 3a   ent-Disp osition:
00e0  20 66 6f 72 6d 2d 64 61  74 61 3b 20 6e 61 6d 65    form-da ta; name
00f0  3d 22 4d 41 58 5f 46 49  4c 45 5f 53 49 5a 45 22   ="MAX_FI LE_SIZE"
0100  0d 0a 0d 0a 34 30 39 36  30 0d 0a 2d 2d 2d 2d 2d   ....4096 0..-----
0110  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d   -------- --------
0120  2d 2d 2d 2d 2d 2d 2d 2d  34 31 31 38 34 36 37 36   -------- 41184676
0130  33 33 34 0d 0a 43 6f 6e  74 65 6e 74 2d 44 69 73   334..Con tent-Dis
0140  70 6f 73 69 74 69 6f 6e  3a 20 66 6f 72 6d 2d 64   position : form-d
0150  61 74 61 3b 20 6e 61 6d  65 3d 22 61 63 74 69 6f   ata; nam e="actio
0160  6e 22 0d 0a 0d 0a 75 70  6c 6f 61 64 0d 0a 2d 2d   n"....up load..--
0170  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d   -------- --------
0180  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 34 31 31 38 34   -------- ---41184
0190  36 37 36 33 33 34 0d 0a  43 6f 6e 74 65 6e 74 2d   676334.. Content-
01a0  44 69 73 70 6f 73 69 74  69 6f 6e 3a 20 66 6f 72   Disposit ion: for
01b0  6d 2d 64 61 74 61 3b 20  6e 61 6d 65 3d 22 62 69   m-data;  name="bi
01c0  6c 64 22 3b 20 66 69 6c  65 6e 61 6d 65 3d 22 6f   ld"; fil ename="o
01d0  6e 2e 62 6d 70 22 0d 0a  43 6f 6e 74 65 6e 74 2d   n.bmp".. Content-
01e0  54 79 70 65 3a 20 69 6d  61 67 65 2f 62 6d 70 0d   Type: im age/bmp.
01f0  0a 0d 0a 42 4d 38 0c 00  00 00 00 00 00 36 00 00   ...BM8.. .....6..
0200  00 28 00 00 00 20 00 00  00 20 00 00 00 01 00 18   .(... .. . ......
0210  00 00 00 00 00 02 0c 00  00 12 0b 00 00 12 0b 00   ........ ........
0220  00 00 00 00 00 00 00 00  00 7b 66 5e 69 53 4d 77   ........ .{f^iSMw
0230  64 5d 76 64 5d 74 64 5e  71 63 5d 74 65 62 71 65   d]vd]td^ qc]tebqe
0240  61 3c 48 5a 3a 42 53 45  47 59 40 40 52 44 45 5a   a<HZ:BSE GY@@RDEZ
0250  36 3d 56 29 3a 55 24 3a  56 35 41 4b 40 4d 5b 3a   6=V):U$: V5AK@M[:
.....hier was ausgelassen......
02d0  8d 87 a2 94 8e a3 95 8f  97 87 81 9b 8b 85 91 81   ........ ........
02e0  7b 9c 89 84 98 85 80 8c  79 74 90 7c 77 86 72 6d   {....... yt.|w.rm
02f0  90 7a 75 8e 78 73 7d 67  62 00 00 0d 0a 2d 2d 2d   .zu.xs}g b....---
0300  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d   -------- --------
0310  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 34 31 31 38 34 36   -------- --411846
0320  37 36 33 33 34 2d 2d 0d  0a                        76334--. .


Hoffe, du kannst damit was anfangen.
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mo 23.01.06 07:27 
@Cix6: Die suche hätte gereicht für deine Frage ;), wenn man sie allgemeiner gehalten hat (also z.B. nur nach DateiUpload gesucht hat): www.delphi-forum.de/...54126&highlight=
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Mo 23.01.06 15:51 
das problem ist, das bei meinem php script bei einem post befehl z.B. mit indy nichts ankommt...mit indy 9 und d7 gehts...bei d4 und indy8 aber nicht...

deswegen habe ich nach anderen lösungen gesucht!
caedes
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 35

Win XP
Delphi 7 Enterprise, C
BeitragVerfasst: Mo 23.01.06 17:34 
Ich würde diesen Weg aber beibehalten, weil er der eleganteste ist. Im Notfalle einfach den POST mit den Socketkomponenten selber zusammenbauen. Kannst ja vorher genau analysieren, was bei indy9 und delphi7 über die Verbindung fließt. Da du ja auch wirklich nur eine einzige Methode der Indys nutzt ist das nachbauen wohl nicht so sehr aufwendig.
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Di 24.01.06 11:18 
ja,aber es muss ja mit d4 und indy8 klappen! rein von der lizenz her arbeite ich nicht mit d7
caedes
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 35

Win XP
Delphi 7 Enterprise, C
BeitragVerfasst: Di 24.01.06 16:51 
Brauchst du ja auch nicht. Das einzige, was du brauchst ist die Komponente TClientsocket, es sei denn musst aus irgendeinem Grund mit den Indys arbeiten. Sie hat mit den Indys nichts zu tun. Mal ein Ansatz, wie ich das machen würde (funktioniert zumindest zur Übergabe normaler Parameter an ein php-script);

ausblenden Delphi-Quelltext
1:
2:
3:
4:
clientsocket1.socket.sendtext('POST /caedes/upload.php HTTP/1.1'+#13+#10+
                                      'Host: www.luminatec.de'+#13+#10+
                                       //Hier den weiteren Header und die Datei mit einfügen
                                       +#13+#10+#13+#10);


Den genauen Aufbau kannst du hier auch nochmal nachvollziehen www.php-faq.de/q/q-code-upload.html. Ist zwar in php geschrieben, aber das ist egal. Man kann es ja einfach übertragen.
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Do 26.01.06 15:07 
tclientsocket ist bei d4 standard nicht dabei!