I see a couple mistakes.
PHP Code:
$url="http://face-book.kvalitne.cz/upload.php";
$referer=$url;
$url = parse_url($url);
$host = $url['host'];
$path = $url['path'];
Right the your assigning the host and path variables the values of an associate array that does not exist. You defining the url variable as a string/char and not as an array. You can create the array and assign the indexes values and that part will be solved. Although I did see that part used.
PHP Code:
$ini = array("url" => "http://face-book.kvalitne.cz/upload.php","host" => "http://www.some_url.com","path" => "C:\somepath\here\");
$referer = $ini['url'];
$url = parse_url($ini['url']);
$host = $ini['host'];
$path = $ini['path'];
The other problem I see is here
PHP Code:
foreach($data as $name => $value) {
$request.=$boundary."\r\n";
if(is_array($value)){
$request.="Content-Disposition: form-data; name=\"$name\"; filename=\"{$value[1]}\"\r\n";
$request.="Content-Type: {$value[2]}\r\n";
$request.="Content-Length: ".strlen($value[0])."\r\n";
$request.="\r\n";
$request.=$value[0]."\r\n";
}
else {
$request.="Content-Disposition: form-data; name=\"$name\"\r\n";
$request.="Content-Length: ".strlen($value)."\r\n";
$request.="\r\n";
$request.=$value."\r\n";
}
}
the part in particular is this
Your basically saying give me the second character of this value. When you use the foreach statement with the key value declaration like you did the value variable is the actual value for that key. Since you only have two values and two commented out for whatever reason your only showing two different key value pairs.
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
for Nahrat
Code:
Content-Type: h
Content-Length: 1
Your going to need to specify the contents type by actually getting the files content type and placing the appropriate value for it. What your doing is saying give me third character of ok which is null, and give me the string length of the character o which is 1. Your not specifying the values correctly and your only showing incomplete values as your headers. Look up acceptable content type and make an array of a function that takes a files extension and returns its content type. Get the string length of the entire text and not just the a specific character. instead of
it should just be
I'm no expert on this matter(emulating a browser) but I can spot errors in code. Try curl instead because its better and more powerful. There are pure php implementations of curl if your host doesn't allow curl or your local machine doesn't have it. Check this site for the pure php curl
http://www.phpclasses.org/search.htm...=0&go_search=1 and this site for content types
http://en.wikipedia.org/wiki/Internet_media_type and this one for header responses
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
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.