Das Script wird jetzt wie von Wunderhand ausgeführt, allerdings wird bei manchen Dateien einfch mal rein Request gesendet, bei anderen schon und wenn kommt immer ein Fehler. Ich bin einfach mal so frei und poste den ganzen Quelltext + den Fehler :
Code: Alles auswählen
#!/usr/bin/python
import cgi
import ftplib
import os.path
import os
import cgitb
import PIL
cgitb.enable()
form = cgi.FieldStorage()
local = form["file"].value
local2 = form["file"].file
print "Content-Type : text/html"
print
print local2
#fsize = os.path.getsize(local)
#if fsize > 60000 :
#print "Content-Type : text/html"
#print
#print 'The file is too big'
ending = os.path.splitext(local)
if ending[1] == '.jpeg' or '.jpg' or '.png' :
dict = 'pics'
list = os.listdir(dict)
print list
count = len(list)
count = count + 1
count = str(count)
conn = ftplib.FTP('ftp-gateway.de','user','passwd')
conn.cwd('/public_html/cgi-bin/pics/')
serverf2 = count+'.pic'
repl = path.replace('\\', os.sep)
print '\n',form["file"].file
conn.storbinary('STOR %s' % serverf2, open(local2, 'rb'))
open(serverf2, 'r')
local2.close()
else :
print "Content-Type : text/html"
print
print 'JPEG and PNG only'
Und hier die Fehler :
Der kommt wenn ich local2 noch einmal in einen Sting Konvertiere (ist im Quelltext oben nicht drin) :
Traceback (most recent call last):
File "/home/w11865/.//web/public_html/cgi-bin/upload.py", line 36, in ?
conn.storbinary('STOR %s' % serverf2, open(local3, 'rb'))
IOError: [Errno 2] No such file or directory: "<open file '(fdopen)', mode 'w+b' at 0x82aa290>"
Der wenn ich einfach local2 nehme :
Traceback (most recent call last):
File "/home/w11865/.//web/public_html/cgi-bin/upload.py", line 36, in ?
conn.storbinary('STOR %s' % serverf2, open(local2, 'rb'))
TypeError: coercing to Unicode: need string or buffer, file found
Es tut mir wirklich leid das ich euch soviele Umstände bereite

Ich bin selber am Verzweifeln
Gruß Hanman