Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 02:58

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



PHP upload mittels curl

Discussion on PHP upload mittels curl within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
YunoSubs's Avatar
 
elite*gold: 0
Join Date: May 2011
Posts: 275
Received Thanks: 49
PHP upload mittels curl

Hi,

ich habe folgendes Problem, ich möchte gerne eine Datei von meinem Server auf einen anderen Server (Video Hoster) hochladen nur will dies nicht funktionieren. Es werden auch keine Errors angezeigt.

Hier ist einmal das Script:
PHP Code:
<?php
class curl
{
         function 
__construct($use 1)
         {
         
$this->ch curl_init();
                 if(
$use 1)
                 {
                         
curl_setopt ($this->chCURLOPT_POST1); // ENABLE HTTP POST
                         
curl_setopt ($this->chCURLOPT_COOKIEJAR'cookie.txt'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
                         
curl_setopt ($this->chCURLOPT_FOLLOWLOCATION1);
                         
curl_setopt ($this->chCURLOPT_RETURNTRANSFER1);
                         
curl_setopt ($this->chCURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
                 }
                 else
                 {
                         return 
'There is the possibility, that this script wont work';
                 }
         }
         function 
first_connect($loginform,$logindata)
         {
                 
curl_setopt($this->chCURLOPT_URL$loginform); // SET URL FOR THE POST FORM LOGIN
                 
curl_setopt($this->chCURLOPT_POSTFIELDS$logindata); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
         
}
         function 
store() //to safe the login
         
{
                 
$store curl_exec ($this->ch);
         }
         function 
execute($page//to move through the intern area
         
{
                 
curl_setopt($this->chCURLOPT_URL$page);
                 
$this->content curl_exec ($this->ch);
         }
         function 
close()
         {
                 
curl_close ($this->ch);
         }

         function 
__toString()
         {
         return 
$this->content;
         }
}



$postdata = array("name" => "file[]",
                     
"filename" => "@".realpath("Hagure.mp4"));
$getit = new curl();
$getit->first_connect('http://yourupload.com/index.php?act=login&login=true','login=true&file_session=&email=&password=dein-passwort&upload=Login'); //Variiert von Seite zu seite. 
$getit->store();
$getit->execute('http://yourupload.com/index.php?act=user&do=home');
$getit->first_connect('http://yourupload.com/index.php?act=files&do=upload',$postdata); //Variiert von Seite zu seite. 
$getit->store();
$getit->close();
?>
Der Login funktioniert aber wunderbar.
Hier das Packet:

Code:
http://yourupload.com/index.php?act=files&do=upload

POST /index.php?act=files&do=upload HTTP/1.1
Host: yourupload.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: text/javascript, text/html, application/xml, text/xml, */*
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
X-Requested-With: XMLHttpRequest
Referer: http://yourupload.com/index.php?act=user&do=home
Content-Length: 41648931
Content-Type: multipart/form-data; boundary=---------------------------265001916915724
Cookie: _pk_ref.9.d1ba=%5B%22%22%2C%22%22%2C1347200605%2C%22http%3A%2F%2F62.75.242.162%2Findex.php%22%5D; _pk_id.9.d1ba=08e499ca1b88c81c.1345157523.12.1347203814.1347189831.; PHPSESSID=jjajqi2mi7fe1blso5qvge9ue5; _pk_ses.9.d1ba=*; member_id=3051; member_pass=xxx
Pragma: no-cache
Cache-Control: no-cache
-----------------------------265001916915724
Content-Disposition: form-data; name="file[]"; filename="Hagure.mp4"
Content-Type: video/mp4


HTTP/1.1 200 OK
Server: nginx/0.7.67
Date: Sun, 09 Sep 2012 15:23:56 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.3.3-7+squeeze13
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Hoffe ihr könnt mir hier weiterhelfen.
YunoSubs is offline  
Old 09/10/2012, 22:05   #2
 
BlackTrader's Avatar
 
elite*gold: 170
Join Date: Mar 2010
Posts: 369
Received Thanks: 187



habs net getestet, sieht aber einfach aus
BlackTrader is offline  
Reply


Similar Threads Similar Threads
PHP - cURL Cookie Problem
08/19/2011 - Web Development - 6 Replies
Hallo, ich möchte eine Chinesische Seite sogesagt übersetzen. Dazu habe ich mir gedacht das ich ein Formular auf Deutsch mache und den Post an die chinesische Seite schicke. Leider bekomme ich eine Fehlermeldung von der Seite aus das die Cookies deaktiviert sind oder so. Nun weiß ich nicht weiter. Cookies sind laut Script an und sollten eig. weitergegebene werden. Könnt ihr mir helfen? <?PHP session_start(); if (isset($_POST) && ($_POST == "Registrieren")){...
help with curl
05/20/2011 - CO2 Programming - 0 Replies
im trying to log in to a page using curl to modify one of my post like updating that specific post with new information over the time i dont understand very much curl and most of the examples i search are in php and i need it to use with autoit or the cmd directly right now im trying from the start, to get logged in the webpage i have found that i need the names of the inputs user and password and that i need a cookie to receive and to send, but when i check the curl.txt in a browser it...
[Projekt] MineTube ~ Video Upload/Bilder Upload und mehr! Team Gesucht
03/23/2011 - Minecraft - 21 Replies
Hallo, Da ich nun seit längerem in der Minecraft Section unterwegs bin und auch so schon lange Erfahrung mit dem Spiel gemacht habe, bin ich zum Entschluss gekommen ein neues Projekt zu starten. Doch was für ein Projekt? Es geht darum, dass viele Minecraft Player, mit Lets Play, Shows und Tutorials anfangen. Dies finde ich natürlich super, aber wieso sollte alles in YouTube un CO untergehen (ausgenommen Gronkh ;) ). Nun gehe ich dazu über, das Projekt namens MineTube zu starten. Was...
[PHP] cUrl Login
04/19/2010 - Web Development - 0 Replies
So ich hab ein kleines Problem. Und zwar versuche ich für das Browsergame Space Pioneers einen Bot mit PHP zu schreiben was generell auch kein Problem wäre, allerdings habe ich ein kleines Problem. Und zwar gibt es zwei möglichkeiten sich einzuloggen, das wäre einmal auf Looki und einmal der Notfall Login Login. Nun zu meinem Problem. Das Einloggen im ersten Link klappt soweit ganz gut, ich habe meines errachtens auch alle Inputs mit übergeben, hat mir allerdings keinen Acceskey...



All times are GMT +1. The time now is 02:58.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.