flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > Windows > Upload file via php | 
  
| Author | 
  | 
              
| 
                  
                   seth0x2b 08 Dec 2006, 14:00 
                  Hey guys...
 
                  
                What I would like to do is this: Upload a file via a php script on my server, without using ftp... This would be the html version of what I want to do... Code: <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> and the php script: Code: $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } I haven't tested it but it seems just about right... I would apreciate any help or advice I can get Thanks in advance  | 
              |||
                  
  | 
              
| 
                  
                   UCM 08 Dec 2006, 15:09 
                  Now how does this have anything at all to do with FASM, or Windows? 
                  
                 | 
              |||
                  
  | 
              
| 
                  
                   WytRaven 08 Dec 2006, 15:20 
                  Code: echo "There was an error processing this post, please try again!"; _________________ All your opcodes are belong to us  | 
              |||
                  
  | 
              
| 
                  
                   seth0x2b 12 Dec 2006, 23:28 
                  I managed to get the upload done with the FtpPutFile API..but I did it with masm32
 
                  
                When I tried "converting" to FASM, I get errors because it can't find the API variables used to connect to the server("INTERNET_OPEN_TYPE_PRECONFIG" would be one of them...) This might be because masm has a wininet.lib included..and FASm hasn't.. MASM: Code: Include wininet.inc IncludeLib wininet.lib .Data appName DB 'Caller', 0 FTPAddress DB 'server', 0 Username DB 'user', 0 Password DB 'pass', 0 localFile DB 'C:\WINDOWS\Zapotec.bmp', 0 remoteFile DB 'Zapotec.bmp', 0 hInternet HANDLE ? hConnect HANDLE ? .Code start: Invoke InternetOpen, Addr appName, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 Mov hInternet, Eax Invoke InternetConnect, hInternet, Addr FTPAddress, INTERNET_DEFAULT_FTP_PORT, Addr Username, Addr Password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 Mov hConnect, Eax Invoke FtpPutFile, hConnect, Addr localFile, Addr remoteFile, FTP_TRANSFER_TYPE_BINARY, 0 Invoke InternetCloseHandle, hConnect Invoke InternetCloseHandle, hInternet Invoke ExitProcess, Eax End start FASM: Code: format pe gui 4.0 entry start include '%finc%\win32a.inc' section ".data" data readable writeable appName DB 'Caller', 0 FTPAddress DB 'server', 0 Username DB 'user', 0 Password DB 'pass', 0 localFile DB 'C:\WINDOWS\Zapotec.bmp', 0 remoteFile DB 'Zapotec.bmp', 0 hInternet dd ? hConnect dd ? section ".code" data readable writeable start: push 0 push 0 push 0 push 0 ;INTERNET_OPEN_TYPE_PRECONFIG push appName call InternetOpen ;Invoke InternetOpen, Addr appName, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 Mov [hInternet], Eax push 0 push INTERNET_FLAG_PASSIVE push INTERNET_SERVICE_FTP push Password push Username push INTERNET_DEFAULT_FTP_PORT push FTPAddress push hInternet call InternetConnect ;Invoke InternetConnect, hInternet, Addr FTPAddress, INTERNET_DEFAULT_FTP_PORT, Addr Username, ; Addr Password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 Mov [hConnect], Eax push 0 push FTP_TRANSFER_TYPE_BINARY push remoteFile push localFile push hConnect call FtpPutFile ;Invoke FtpPutFile, hConnect, Addr localFile, Addr remoteFile, FTP_TRANSFER_TYPE_BINARY, 0 push hConnect call InternetCloseHandle ;Invoke InternetCloseHandle, hConnect push hInternet call InternetCloseHandle ;Invoke InternetCloseHandle, hInternet call Exitprocess ;Invoke ExitProcess, Eax section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ wininet,'WININET.DLL' import kernel32,\ ExitProcess,'ExitProcess' import wininet,\ InternetOpen,'InternetOpenA',\ InternetConnect,'InternetConnectA',\ FtpPutFile,'FtpPutFileA',\ InternetCloseHandle,'InternetCloseHandleA' I'll apreciate any feedback Thanks in advance. Cheers  | 
              |||
                  
  | 
              
| 
                  
                   LocoDelAssembly 12 Dec 2006, 23:51 
                  fasm has "invoke" too, though, note that "Invoke" is different to "invoke"  
                  
                About the constant, add it by your self. I usually extract from masm packages some constants that fasm packages lacks of.  | 
              |||
                  
  | 
              
| 
                  
                   RedGhost 13 Dec 2006, 00:03 
                  seth0x2b, the fasm defines are ones Tomasz has added, probably from C headers, if one is missing, define it yourself. 
                  _________________ redghost.ca  | 
              |||
                  
  | 
              
| 
                  
                   madmatt 13 Dec 2006, 05:49 
                  You can look on my website and get some extra includes: http://users.egl.net/talktomatt/default.html 
                  
                 | 
              |||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.