Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
InternetWriteFile
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00939833
Message ID:
00939980
Views:
18
FUNCTION local2ftp (hConnect, lcSource, lcTarget)
* copying local file to the remote target
	hSource = FOPEN (lcSource)
	IF (hSource = -1) 
		RETURN -1
	ENDIF

	* this call creates a new remote file
	hTarget = FtpOpenFile(hConnect, lcTarget, GENERIC_WRITE,;
		FTP_TRANSFER_TYPE_BINARY, 0)
	IF hTarget = 0
		= FCLOSE (hSource)
		RETURN -2
	ENDIF

	lnBytesWritten = 0
	lnChunkSize = 256	&& 128, 512 and even 16384 are good

	DO WHILE Not FEOF(hSource)
		lcBuffer = FREAD (hSource, lnChunkSize)
		lnLength = Len(lcBuffer)
		IF lnLength > 0
			IF InternetWriteFile (hTarget, @lcBuffer, lnLength, @lnLength) = 1
				lnBytesWritten = lnBytesWritten + lnLength
				* at this point you can display the progress
				* and test events: keyboard, mouse etc.
				* to decide on aborting the upload
				?? "·"	&& you can put link to a progress bar here instead
			ELSE
				EXIT
			ENDIF
		ELSE
			EXIT
		ENDIF
	ENDDO
	= InternetCloseHandle (hTarget)
	= FCLOSE (hSource)
RETURN  lnBytesWritten
Check also:

Uploading file to the FTP server using InternetWriteFile
http://www.news2news.com/vfp/?example=62&function=93

Custom FTP Class for Visual FoxPro application
http://www.news2news.com/vfp/?example=344&function=93
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform