Witam, próbuję przesłać obrazek za pomocą Curl'a ale nie wychodzi.

oto plik do którego chcę przesłać obrazek
  1. <?php
  2. /*
  3.  * FCKeditor - The text editor for Internet - <a href="http://www.fckeditor.net" target="_blank">http://www.fckeditor.net</a>
  4.  * Copyright (C) 2003-2007 Frederico Caldeira Knabben
  5.  *
  6.  * == BEGIN LICENSE ==
  7.  *
  8.  * Licensed under the terms of any of the following licenses at your
  9.  * choice:
  10.  *
  11.  * - GNU General Public License Version 2 or later (the "GPL")
  12.  * <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">http://www.gnu.org/licenses/gpl.html</a>
  13.  *
  14.  * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15.  * <a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">http://www.gnu.org/licenses/lgpl.html</a>
  16.  *
  17.  * - Mozilla Public License Version 1.1 or later (the "MPL")
  18.  * <a href="http://www.mozilla.org/MPL/MPL-1.1.html" target="_blank">http://www.mozilla.org/MPL/MPL-1.1.html</a>
  19.  *
  20.  * == END LICENSE ==
  21.  *
  22.  * This is the "File Uploader" for PHP.
  23.  */
  24.  
  25. require('config.php') ;
  26. require('util.php') ;
  27.  
  28. // This is the function that sends the results of the uploading process.
  29. function SendResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
  30. {
  31. echo '<script type="text/javascript">' ;
  32. echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace( '"', '\\"', $fileUrl ) . '","' . str_replace( '"', '\\"', $fileName ) . '", "' . str_replace( '"', '\\"', $customMsg ) . '") ;' ;
  33. echo '</script>' ;
  34. exit ;
  35. }
  36.  
  37. // Check if this uploader has been enabled.
  38. if ( !$Config['Enabled'] )
  39. SendResults( '1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/upload/php/config.php" file' ) ;
  40.  
  41. // Check if the file has been correctly uploaded.
  42. if ( !isset( $_FILES['NewFile'] ) || is_null( $_FILES['NewFile']['tmp_name'] ) || $_FILES['NewFile']['name'] == '' )
  43. SendResults( '202' ) ;
  44.  
  45. // Get the posted file.
  46. $oFile = $_FILES['NewFile'] ;
  47.  
  48. // Get the uploaded file name extension.
  49. $sFileName = $oFile['name'] ;
  50.  
  51. // Replace dots in the name with underscores (only one dot can be there... security issue).
  52. if ( $Config['ForceSingleExtension'] )
  53. $sFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sFileName ) ;
  54.  
  55. $sOriginalFileName = $sFileName ;
  56.  
  57. // Get the extension.
  58. $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
  59. $sExtension = strtolower( $sExtension ) ;
  60.  
  61. // The the file type (from the QueryString, by default 'File').
  62. $sType = isset( $_GET['Type'] ) ? $_GET['Type'] : 'File' ;
  63.  
  64. // Check if it is an allowed type.
  65. if ( !in_array( $sType, array('File','Image','Flash','Media') ) )
  66. SendResults( 1, '', '', 'Invalid type specified' ) ;
  67.  
  68. // Get the allowed and denied extensions arrays.
  69. $arAllowed = $Config['AllowedExtensions'][$sType] ;
  70. $arDenied = $Config['DeniedExtensions'][$sType] ;
  71.  
  72. // Check if it is an allowed extension.
  73. if ( ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) || ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) )
  74. SendResults( '202' ) ;
  75.  
  76. $sErrorNumber = '0' ;
  77. $sFileUrl = '' ;
  78.  
  79. // Initializes the counter used to rename the file, if another one with the same name already exists.
  80. $iCounter = 0 ;
  81.  
  82. // Get the target directory.
  83. if ( isset( $Config['UserFilesAbsolutePath'] ) && strlen( $Config['UserFilesAbsolutePath'] ) > 0 )
  84. $sServerDir = $Config['UserFilesAbsolutePath'] ;
  85. else
  86. $sServerDir = GetRootPath() . $Config["UserFilesPath"] ;
  87.  
  88. if ( $Config['UseFileType'] )
  89. $sServerDir .= strtolower($sType) . '/' ;
  90.  
  91. //check for the directory before uploading the file
  92. if(!is_dir($sServerDir))
  93. {
  94. mkdir($sServerDir);
  95. }
  96.  
  97. while ( true )
  98. {
  99. // Compose the file path.
  100. $sFilePath = $sServerDir . $sFileName ;
  101.  
  102. // If a file with that name already exists.
  103. if ( is_file( $sFilePath ) )
  104. {
  105. $iCounter++ ;
  106. $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
  107. $sErrorNumber = '201' ;
  108. }
  109. else
  110. {
  111. move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
  112.  
  113. if ( is_file( $sFilePath ) )
  114. {
  115. $oldumask = umask(0) ;
  116. chmod( $sFilePath, 0777 ) ;
  117. umask( $oldumask ) ;
  118. }
  119.  
  120. if ( $Config['UseFileType'] )
  121. $sFileUrl = $Config["UserFilesPath"] . strtolower($sType) . '/' . $sFileName ;
  122. else
  123. $sFileUrl = $Config["UserFilesPath"] . $sFileName ;
  124.  
  125. break ;
  126. }
  127. }
  128.  
  129. SendResults( $sErrorNumber, $sFileUrl, $sFileName ) ;
  130. ?>


a tutaj mój plik z curlem
  1. <?php
  2. class mycurl {
  3.  
  4. protected $_useragent = 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100715 Linux Mint/9 (Isadora) Firefox/3.6.7';
  5. protected $_url;
  6. protected $_followlocation;
  7. protected $_timeout;
  8. protected $_maxRedirects;
  9. protected $_cookieFileLocation = './cookie.txt';
  10. protected $_post;
  11. protected $_postFields;
  12. protected $_referer ="http://www.google.com";
  13.  
  14. protected $_session;
  15. protected $_webpage;
  16. protected $_includeHeader;
  17. protected $_noBody;
  18. protected $_status;
  19. protected $_binaryTransfer;
  20. public $authentication = 0;
  21. public $auth_name = '';
  22. public $auth_pass = '';
  23.  
  24. public function useAuth($use){
  25. $this->authentication = 0;
  26. if($use == true) $this->authentication = 1;
  27. }
  28.  
  29. public function setName($name){
  30. $this->auth_name = $name;
  31. }
  32. public function setPass($pass){
  33. $this->auth_pass = $pass;
  34. }
  35.  
  36. public function __construct($url,$followlocation = true,$timeOut = 30,$maxRedirecs = 4,$binaryTransfer = false,$includeHeader = false,$noBody = false)
  37. {
  38. $this->_url = $url;
  39. $this->_followlocation = $followlocation;
  40. $this->_timeout = $timeOut;
  41. $this->_maxRedirects = $maxRedirecs;
  42. $this->_noBody = $noBody;
  43. $this->_includeHeader = $includeHeader;
  44. $this->_binaryTransfer = $binaryTransfer;
  45.  
  46. $this->_cookieFileLocation = dirname(__FILE__).'/cookie.txt';
  47.  
  48. }
  49.  
  50. public function setReferer($referer){
  51. $this->_referer = $referer;
  52. }
  53.  
  54. public function setCookiFileLocation($path)
  55. {
  56. $this->_cookieFileLocation = $path;
  57. }
  58.  
  59. public function setPost ($postFields)
  60. {
  61. $this->_post = true;
  62. $this->_postFields = $postFields;
  63. }
  64.  
  65. public function setUserAgent($userAgent)
  66. {
  67. $this->_useragent = $userAgent;
  68. }
  69.  
  70. public function createCurl($url = 'nul')
  71. {
  72. if($url != 'nul'){
  73. $this->_url = $url;
  74. }
  75.  
  76. $s = curl_init();
  77.  
  78. curl_setopt($s,CURLOPT_URL,$this->_url);
  79. curl_setopt($s,CURLOPT_HTTPHEADER,array('Expect:'));
  80. curl_setopt($s,CURLOPT_TIMEOUT,$this->_timeout);
  81. curl_setopt($s,CURLOPT_MAXREDIRS,$this->_maxRedirects);
  82. curl_setopt($s,CURLOPT_RETURNTRANSFER,true);
  83. curl_setopt($s,CURLOPT_FOLLOWLOCATION,$this->_followlocation);
  84. curl_setopt($s,CURLOPT_COOKIEJAR,$this->_cookieFileLocation);
  85. curl_setopt($s,CURLOPT_COOKIEFILE,$this->_cookieFileLocation);
  86.  
  87. if($this->authentication == 1){
  88. curl_setopt($s, CURLOPT_USERPWD, $this->auth_name.':'.$this->auth_pass);
  89. }
  90. if($this->_post)
  91. {
  92. curl_setopt($s,CURLOPT_POST,true);
  93. curl_setopt($s,CURLOPT_POSTFIELDS,$this->_postFields);
  94.  
  95. }
  96.  
  97. if($this->_includeHeader)
  98. {
  99. curl_setopt($s,CURLOPT_HEADER,true);
  100. }
  101.  
  102. if($this->_noBody)
  103. {
  104. curl_setopt($s,CURLOPT_NOBODY,true);
  105. }
  106. /*
  107.   if($this->_binary)
  108.   {
  109.   curl_setopt($s,CURLOPT_BINARYTRANSFER,true);
  110.   }
  111.   */
  112. curl_setopt($s,CURLOPT_USERAGENT,$this->_useragent);
  113. curl_setopt($s,CURLOPT_REFERER,$this->_referer);
  114.  
  115. $this->_webpage = curl_exec($s);
  116. $this->_status = curl_getinfo($s,CURLINFO_HTTP_CODE);
  117. curl_close($s);
  118.  
  119. }
  120.  
  121. public function getHttpStatus()
  122. {
  123. return $this->_status;
  124. }
  125.  
  126. public function __tostring(){
  127. return $this->_webpage;
  128. }
  129. }
  130.  
  131. $wyslij_obrazek = new mycurl('');
  132. $_FILES['NewFile'] = "@Google-logo.jpg";
  133. $_FILES['NewFile']['tmp_name'] = 'products';
  134. $_FILES['NewFile']['name'] = 'Google-logo.jpg';
  135. $wyslij_obrazek->setPost($_FILES);
  136. $wyslij_obrazek->createCurl('http://adres-strony.pl/administracja/includes/javascript/FCKeditor/editor/filemanager/upload/php/upload.php?Type=Image');
  137. ?>



proszę was o pomoc i nakierowanie na właściwą drogę