Vamos supor quê, vc tem uma página na sua casa/escritório e quer deixar um site online, (usar aquele CPU velho esquecido)
Instale o Linux nele com apache e o harbour.
"MadarArquivo.html"
<form action="/cgi-bin/PegarArquivo.prg" enctype="multipart/form-data" method="post">
<p> Descrição do documento:<br>
<input type="text" name="observacao" size="30"></p>
<p> Informe o arquivo.<br>
<input type="file" name="datafile" size="40"></p>
<div><input type="submit" value="Enviar">
</div>
</form>
"PegarArquivo.prg"
#!/usr/local/bin/hbrun
#include "fileio.ch"
******************
Function Main(...)
******************
*
*
LOCAL cTemp:="", nRead, nLen
LOCAL cEOL := + hb_eol() + hb_eol()
LOCAL cArq, nPosKey, nInicio, nFim, hFileInput
LOCAL cInicio, cFim, xContent:="", xFile, cBuff, cOut
if "POST" $ Upper( hb_GetEnv( "REQUEST_METHOD" ) )
nLen := val(hb_getenv("CONTENT_LENGTH"))
cBuff := space(nLen)
endif
outstd( "Content-type: text/html" + cEOL )
Outstd( "<!DOCTYPE html>" + hb_eol() )
OutStd("<html><head>" + hb_eol() )
OutStd('<meta charset="UTF-8"/>' + hb_eol() )
OutStd('<pre>')
OutStd( "Tamanho: " + str(nLen) + hb_eol() )
Do while .T.
nRead := FRead( hb_GetStdIn(), @cBuff, hb_BLen( cBuff ) )
Do case
case nRead == -1
OutStd("Erro lendo stdin: " + hb_ntos( ferror()) + hb_eol() )
exit
case nRead == 0
exit
EndCase
cOut := hb_BLeft( cBuff, nRead )
if hb_BLen( cOut ) > 0
xContent += cOut
endif
enddo
nPosKey := hb_at("filename",xContent)
nInicio := hb_At("=",xContent,nPosKey)+2
nFim := hb_At('"', xContent, hb_At('"',xContent,nPosKey)+1 )
cArq := SubStr(xContent,nInicio, (nFim - nInicio) )
//outstd( substr(xContent,1,250) + hb_eol() )
cInicio := substr( xContent,1,hb_at(hb_eol(),xContent)-2 ) //chr(13)+chr(10)
outstd("inicio do, " + cArq + ": " + hb_eol() + cInicio + hb_eol() )
cFim := cInicio + "--"
outstd("fim:" + hb_eol() + cFim + hb_eol() )
nInicio := hb_At("Content-Type:", xContent )
nInicio := hb_At(hb_eol(),xContent,nInicio) + 3
outstd("inicio:" + Str(nInicio) + hb_eol() )
nFim := hb_At(cFim,xContent)-1
xFile := substr(xContent,nInicio, (nFim - nInicio) )
hFileInput := hb_vfopen( cArq, FO_CREAT + FO_TRUNC + FO_WRITE)
hb_vfwrite(hFileInput,xFile)
hb_vfclose(hFileInput)
return OutStd("</pre></body></html>" )
Tem sua foto no zapzap, etc... pode enviar qualquer arquivo.
Se tem harbour tem CGI!
Saudações,
Itamar M. Lins Jr.