Hello.
I have written a very simple script to send a multipart POST request to server.
I don't see any difference between the request send by PHP script and the one send from firefox, but the remote site has empty both $_POST and $_FILES when the request comes from my site.
I've included the source code.
|
Ambitious contributor
|
|
| 12Jul2011,07:54 | #2 |
|
I see a couple mistakes.
PHP Code:
PHP Code:
PHP Code:
PHP Code:
upload => ok potvrd => Nahrát each time the code is ran the values for that character as given and not the value as a whole. For an example the content could be shown as this: for ok Code:
Content-Type: null Content-Length: 1 Code:
Content-Type: h Content-Length: 1 PHP Code:
PHP Code:
edit: link to curl emulator in php http://code.blitzaffe.com/pages/phpc..._emulator_52-7 and curl function guide http://php.net/manual/en/ref.curl.php Best of luck to you mate. Last edited by pein87; 12Jul2011 at 08:28.. |
|
Go4Expert Member
|
|
| 14Jul2011,23:31 | #3 |
|
Hello, thank you very much, for exploring my (uncomented, sorry) code.
But both errors werent errors actually. I've written a long explanation yesterday, but the fucki'n storm has shut down electric network I will not wtire it so detailed again, sorry. 1. st error: parse_url returns array. 2 nd. error: There are an if(is_array(...)) statement. But you've shared some usefull links for me, and I will try to use them and make the script another way. So thank you for your time and for wishing me luck. |
|
Ambitious contributor
|
|
| 15Jul2011,15:24 | #4 |
|
I didn't know it returned an array(I've never used it), however it may not have that key. Make sure you first check to make sure its an array and that that array key exists.
you should use this PHP Code:
PHP Code:
Code:
upload : o potvrd: N PHP Code:
the testing for if its an array in a foreach loop is not needed. You already hard coded it as an array so testing for it to be one is ridiculous, because you already know its an array. If anything you should have tested before hand if its an array because that function will be called every iteration and consume unneeded memory. Php allows for char level variable output and thats why what your doing in the foreach loop is wrong and poor coding in general. Don't take my word though, output that data during iteration and see for yourself the values it gives you. As far as getting content types, well you'll need to probably use regex to get all the data after the .(because some formats use 4 characters for their extension instead of 3) or substr(). Compare that value to predefined values and return the appropriate content type. Last edited by pein87; 15Jul2011 at 15:28.. |
|
Go4Expert Member
|
|
| 15Jul2011,21:56 | #5 |
|
See here
jmareda.tk/roboti/uploader.phpThe code is almost (maybe absolutely) the same as uploaded. And about the file types: in older PHP versions, I can use file_content_mime_type (or somethink like that) but one of goals of the script was to test, if the professional upload servers are testing the mime type as I do, or they simply use the header. Because, as we see here, if the script worked, the header could be faked... About the values and arrays: I've written the script to work witch array, which contains values and arrays together. It is because now i can know: Its an array - its a file upload. Otherwise, its a post field, which has only name, nothing else. Actually, after some more tests, header changes and so on, i've really strong suspition, that there are some server anti hack on my or remote hosting. |
|
Go4Expert Member
|
|
| 15Jul2011,21:57 | #6 |
stupid site told me that one URL is too many links. Internet hates me today, facebook also pissed me of. Or fired me out, said better. I'm gonne hack them as a revanche one day.
|
|
Ambitious contributor
|
|
| 17Jul2011,05:49 | #7 |
|
So your basically trying to make this an upload script? Why not just create an upload page? What exactly are you trying to upload and to where? Using ajax, and php you could create an intuitive ui with excellence features. If you wanted to send a file why not use curl or heck even ftp functions in a client server system. You could create a simple multi-file upload using simple code. Of you could upload from a folder to a remote server using curl or the ftp functions. I think you need to develop the idea farther and determine exactly what you want this script to do and how you can implement each feature. You could also use this function which works better and is faster. http://www.php.net/manual/en/function.finfo-file.php
There are so many ways to tackle the task that you've set up but you need to first understand what it is your trying to do. As far as your idea you need a client to receive the file and process it and a server that does the actual labor. Of course you could have multiple clients that use the server but a client server system is probably your best shot. You could also write a p2p system but using php it would be very limited to just being a web or crude cli program.
Darker
like this
|
|
Go4Expert Member
|
|
| 17Jul2011,15:52 | #8 |
|
Actually, if i wantet to send files to servers where I have FTP access i would use something else. But once i want to send data somewhere else (like some kiddie upload script) I want to make this.
And once O realised that its not easy, it became also a bit chalenge for me ![]() Thank you for link to new version of file_mime_type ![]() But actually, I maybe want to do not send mime types with files correctly, to test skils of my frinds (and enemies )
|

jmareda.tk/roboti/uploader.php
stupid site told me that one URL is too many links. Internet hates me today, facebook also pissed me of. Or fired me out, said better. I'm gonne hack them as a revanche one day.