Jump to content

Recommended Posts

  • 2 weeks later...
Posted
On 04/07/2016 at 11:59 AM, trancexx said:

The same way how? You can or you can't?

I am doing it the exact same way, I can log in from my browser on both, not on my script.

Posted
On 13/07/2016 at 5:00 PM, trancexx said:

You need to give me more info. It works on all sites I have access to.

Here's an idea... give me your credentials. Hah!

That would be the easiest without a doubt, but unfortunately I cannot do so :/
I'll have to figure something out on my own I guess, but thank you thus far :>

  • 4 years later...
Posted (edited)
On 6/26/2016 at 3:26 PM, trancexx said:

np

It could be like this:

#include "WinHttp.au3"


$sDomain = "http://myurl.com/"
$sLoginPage = "/wp-login.php"
$sUploadPage = "/wp-admin/media-new.php"

$sLoginName = "username"
$sPassword = "mypassword"

; Choose file to upload
$sFileToUpload = FileOpenDialog("Choose something (Image better maybe?)", "", "All (*.*)")
If $sFileToUpload Then
    $hOpen = _WinHttpOpen()
    $hConnect = _WinHttpConnect($hOpen, $sDomain)

    ; Login first
    _WinHttpSimpleFormFill($hConnect, _
            $sLoginPage, _
            "loginform", _
            'user_login', $sLoginName, _
            'user_pass', $sPassword)

    ConsoleWrite('! Error for login = ' & @error & @LF)

    _WinHttpSimpleFormFill($hConnect, _
            $sUploadPage, _
            "file-form", _
            'async-upload', $sFileToUpload)

    ConsoleWrite('! Error for upload = ' & @error & @LF)


    _WinHttpCloseHandle($hConnect)
    _WinHttpCloseHandle($hOpen)
EndIf

 

the code was working very well but I don't know what happened !

I re-use the same code above with my all wordpress sites 

suddenly I faced the error login = 4 or 1 and can't upload an image

please help I need it so much  

Edited by AlienStar
Posted

@AlienStar

 

You need to specify you goals and your issus *FAAAR* more precisely!

 

Same as in the other thread with your INI section task ...😉

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Posted (edited)
15 hours ago, rudi said:

@AlienStar

 

You need to specify you goals and your issus *FAAAR* more precisely!

 

Same as in the other thread with your INI section task ...😉

first, thanks so much my friend for help :)

next, image upload code was working well and I don't know what happened after a while so I can't upload and send me upload error

that's why I've searched a lot then found the solution :)

using IE functions I reach the image upload page then select the image 

Local $url = $sDomain&"/wp-admin/media-new.php?browser-uploader"
Local $oIE_img =_IECreate($url)
_IELoadWait($oIE_img)
Local $async_upload = _IEGetObjById($oIE_img, "async-upload")
Local $upload_btn = _IEGetObjById($oIE_img, "html-upload")
_IEAction($async_upload, "focus")
Local $hIE = _IEPropertyGet($oIE_img, "hwnd")
ControlSend($hIE, "", "Internet Explorer_Server1", " ")
WinWait("Choose File to Upload", "", 10)
Sleep(1000)
WinActivate("Choose File to Upload")
ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", $IMG_Loc)
Sleep(1000)
WinActivate("Choose File to Upload")
ControlSend("Choose File to Upload", "", "", "{ENTER}")
WinWaitClose("Choose File to Upload", "", 1)
_IEAction($upload_btn, "click")

 

Edited by AlienStar

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...