Jump to content

oWinHttp.Open POST question - (Moved)


Recommended Posts

Hi guys,

I'm trying to upload files to my server using a simple php created by me, but it seems that it only manages to send 18 kb of the album image. what can I do?

Global $oWinHttp

$sURL = "https://site.com/dir/phpfile.php"
$Img_album = "album.jpg"

$sread = FileRead($Img_album)

$oWinHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")

$oWinHttp.Open("POST", $sURL, False)
$oWinHttp.SetRequestHeader("Content-Type", "image/jpeg")
$oWinHttp.SetRequestHeader("Content-Length", FileGetSize($Img_album))
$oWinHttp.Send($sread)


If $oWinHttp.Status <> 200 Then
    MsgBox(16, "Error", "Error: " & $oWinHttp)
EndIf

 

phpfile.php

<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

  file_put_contents('album.jpg', file_get_contents('php://input'));

  http_response_code(200);
  exit;
}

if ($_SERVER['REQUEST_METHOD'] == 'GET') {

  header('Content-Type: image/jpeg');
  readfile('album.jpg');
 // exit;
}

http_response_code(400);

 

Link to post
Share on other sites
  • Developers

Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...