Sign in to follow this  
Followers 0
autoitxp

PHP upload file name issue

1 post in this topic

This is part of my script . I need to know how to rename or change upload.zip file name to desired one i tryed using $_POST method but unsuccessful

php code 

<?php
print_r($_POST);
print_r($_FILES);
copy($_FILES["upload"]["tmp_name"], "upload.zip");
?>

 

ConsoleWrite(_PHPupload('192.168.1.2', _OSmacros(), 89, '/upload/index.php', 'application/zip') & @CRLF)

Func _PHPupload($pIP, $pMacros, $pPort, $phpPath, $pContent)
    If FileExists($pFile) = 0 Then Return SetError(1, 1, '')
    $pTcpc = TCPConnect($pIP, $pPort)
    If @error Then Return SetError(1, 2, '')
    Local $pBound = "-----" & Random(10000000, 99999999, 1)
    Local $pData1 = "--" & $pBound & @CRLF
    $pData1 &= 'Content-Disposition: form-data; name="upload";  filename="' & $pFile & '"' & @CRLF & 'Content-Type: ' & $pContent & @CRLF & @CRLF
    Local $pData2 = @CRLF & "--" & $pBound & @CRLF & 'Content-Disposition: form-data ;name="test"' & @CRLF & @CRLF & "variable" & @CRLF
    $pData2 &= "--" & $pBound & "--" & @CRLF & @CRLF
    Local $pHeader = 'POST ' & $phpPath & ' HTTP/1.1' & @CRLF
    $pHeader &= 'Host: ' & $pIP & @CRLF
    $pHeader &= 'User-Agent: ' & $pMacros & @CRLF
    $pHeader &= 'Content-Type: multipart/form-data; boundary=' & $pBound & @CRLF
    $pHeader &= 'Content-Length: ' & (StringLen($pData1) + StringLen($pData2) + FileGetSize($pFile)) & @CRLF & @CRLF
    Local $pFopen = FileOpen($pFile, $FO_READ)
    If $pFopen = -1 Then Return SetError(1, 3, '')
    Local $sFread = FileRead($pFopen)
    TCPSend($pTcpc, $pHeader & $pData1 & $sFread & $pData2)
    If @error Then Return SetError(1, 4, '')


    Local $pBuffer = ""

    While 1
        $pBuffer &= TCPRecv($pTcpc, 1024)
        If @error Then
            Return SetError(1, 5, '')
        Else
            ExitLoop
        EndIf
    WEnd

    MsgBox(64, "", $pBuffer)

EndFunc   ;==>_PHPupload

 

Share this post


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
Sign in to follow this  
Followers 0