Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IntPost problem
#1
IntPost is not working for me.

Code:
Copy      Help
;;posts form with file field (userfile)
str s sr
s.getfile("$desktop$\test.txt")
s-"--7d23542a1a12c2[]Content-Disposition: form-data; name=''userfile''; filename=''test.txt''[]Content-Type: text/plain[][]"
s+"--7d23542a1a12c2--[]"
IntPost "http://www.nightchatter.com/uploader.php" s sr "Content-Type: multipart/form-data; boundary=7d23542a1a12c2"
out sr

here is the page for manual upload:
http://www.nightchatter.com/upload.htm

uploader.php code
Code:
Copy      Help
<?php

$uploadDir = $_SERVER['DOCUMENT_ROOT'].'/temp/';

$uploadFile = $uploadDir . $_FILES['userfile']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile))
{
    print "File is valid, and was successfully uploaded. ";
    print "Here's some more debugging info:";
    print_r($_FILES);
}
else
{
    print "Possible file upload attack!  Here's some debugging info:";
    print_r($_FILES);
}
print "</pre>";
?>

html upload form code
Code:
Copy      Help
<html>
<head>
<title>upload test</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>

<body bgcolor='#ffffff' text='#000000'>

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000" />
Choose a file to upload: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>

any idea ?
pi
#2
please give me feedback.
pi
#3
Is it really not working? I just tried the QM code and here is sr:

<pre>File is valid, and was successfully uploaded. Here's some more debugging info:Array
(
[userfile] => Array
(
[name] => test.txt
[type] => text/plain
[tmp_name] => /tmp/phpZgNMFc
[error] => 0
[size] => 934
)

)
</pre>
#4
i get on every file 'Possible file upload attack! Here's some debugging info:Array'

error 3 - The uploaded file was only partially uploaded.
pi
#5
Is it really txt file? If no, try different content-type header. What is file size? I tested with small file.
#6
i tested it with your upload file too.
i use a router, but this can't be the problem.
pi
#7
Try to replace Http.Post text to

Code:
Copy      Help
function# $action $frmdata [str&responsepage] [$headers]

;Posts web form data. At first, call Connect.
;Returns 1 on success, 0 on failure.
;action - script's path relative to server.
;frmdata - urlencoded string. To urlencode, use str.escape.
;responsepage - if used, is populated with contents of response page (html).
;headers - additional headers. Default: "Content-Type: application/x-www-form-urlencoded"


;See also: <IntPost> function.


int hiopen=inet.HttpOpenRequest(m_hi "POST" action 0 0 0 inet.INTERNET_FLAG_RELOAD 0); if(!hiopen) goto(e)
if(!len(headers)) headers="Content-Type: application/x-www-form-urlencoded"
int r=inet.HttpSendRequest(hiopen headers -1 frmdata len(frmdata)); if(!r) goto(e)

if(&responsepage)
,int size
,responsepage.all
,rep
,,if(!inet.InternetQueryDataAvailable(hiopen &size 0 0)) break
,,if(size)
,,,responsepage.all(responsepage.len+size 1)
,,,if(!inet.InternetReadFile(hiopen responsepage+responsepage.len size &size)) goto e
,,responsepage.fix(responsepage.len+size)
,,if(size=0) break

inet.InternetCloseHandle hiopen
ret 1
;e
if(hiopen) inet.InternetCloseHandle hiopen
Error

Fixed 2 small bugs, but it probably will not change anything.
#8
that may sound stupid, but how do i edit the system.qml ?
pi
#9
Right click System, click Folder Properties, uncheck read-only. To save after editing, export-replace System.
#10
thanks, but no change.
pi
#11
thats weird, when a text file has only 1 line then it does't work.

how do i upload jpeg ?
i changed the content-type to image/jpeg, but where to find the right boundary value ?
pi
#12
Boundary values are user-defined. Use the same.

I don't know, maybe the image should be encrypted using base64 algorithm, and "Content-Transfer-Encoding: base64" header added, like in email messages.
#13
i found a tiny vb6 project file and changed the path for upload.
in this example posting images works.

can you please take a look on it, maybe you find what is wrong with IntPost.
(uploader.php and a test.jpg are included in the zip.)

thanks


Attached Files
.zip   http_post.zip (Size: 6.67 KB / Downloads: 456)
pi
#14
any progress on this topic ?

when it would work then one can upload pictures via contextmenu
and the result (functions behind ...) will be available as bbcode or xhtml,

which is very useful when working in social networks.
pi
#15
Code:
Copy      Help
int useIE=1

str s sh sr
s.getfile("$desktop$\test.txt")
;s.getfile("$qm$\winapiqm.txt")
s-"--7d23542a1a12c2[]Content-Disposition: form-data; name=''userfile''; filename=''test.txt''[]Content-Type: text/plain[][]"
s+"--7d23542a1a12c2--[]"
sh="Content-Type: multipart/form-data; boundary=7d23542a1a12c2[]"

if(!useIE)
,IntPost "http://www.nightchatter.com/uploader.php" s sr sh
else
,VARIANT v vh
,vh=sh
,ARRAY(byte) a.create(s.len+1)
,memcpy(&a[0] s a.len)
,v.attach(a)
,
,int h=win
,SHDocVw.InternetExplorer b._create
,act h
,b.Navigate("http://www.nightchatter.com/uploader.php" @ @ v vh)
,;b.Navigate("http://www.google.com")
,1
,rep() 0.1; if(!b.Busy) break
,MSHTML.IHTMLDocument2 doc=b.Document
,sr=doc.body.innerText

out sr
#16
image upload is still not working for me.
Sad
pi
#17
how with text files?
#18
text works.
pi
#19
Try to change conten-type header and encrypt using base64. See headers in multipart email messages.
#20
its still not working.

http_upload
Code:
Copy      Help
ClearOutput
int useIE=1

str s sh sr
s.getfile("$desktop$\test.png")
s.encrypt(4)
s-"--7d23542a1a12c2[]Content-Disposition: form-data; name=''userfile''; filename=''test.png''[]Content-transfer-encoding: base64[]"
s+"--7d23542a1a12c2--[]"
sh="Content-Type: multipart/form-data; boundary=7d23542a1a12c2[]"

if(!useIE)
,IntPost "http://www.nightchatter.com/uploader.php" s sr sh
else
,VARIANT v vh
,vh=sh
,ARRAY(byte) a.create(s.len+1)
,memcpy(&a[0] s a.len)
,v.attach(a)
,
,int h=win
,SHDocVw.InternetExplorer b._create
,act h
,b.Navigate("http://www.nightchatter.com/uploader.php" @ @ v vh)
,1
,rep() 0.1; if(!b.Busy) break
,MSHTML.IHTMLDocument2 doc=b.Document
,sr=doc.body.innerText

out sr
pi
#21
New line was missing after file data. I also added Content-type.

Code:
Copy      Help
ClearOutput
int useIE=1

str s sh sr
s.getfile("$desktop$\test.png")
s.encrypt(4)
s-"--7d23542a1a12c2[]Content-Disposition: form-data; name=''userfile''; filename=''test.png''[]Content-Type: image/png[]Content-transfer-encoding: base64[][]"
s+"[]--7d23542a1a12c2--[]"
sh="Content-Type: multipart/form-data; boundary=7d23542a1a12c2[]"

;out s

if(!useIE)
,IntPost "http://www.nightchatter.com/uploader.php" s sr sh
else
,VARIANT v vh
,vh=sh
,ARRAY(byte) a.create(s.len+1)
,memcpy(&a[0] s a.len)
,v.attach(a)
,
,int h=win
,SHDocVw.InternetExplorer b._create
,act h
,b.Navigate("http://www.nightchatter.com/uploader.php" @ @ v vh)
,1
,rep() 0.1; if(!b.Busy) break
,MSHTML.IHTMLDocument2 doc=b.Document
,sr=doc.body.innerText

out sr

Also works when useIE=0.
#22
you rock !!!
pi


Forum Jump:


Users browsing this thread: 3 Guest(s)