FTP Upload Download | Image upload Download

Source: Internet
Author: User


Popup Input file path hint
* *. Open File Dialog
Call METHOD Cl_gui_frontend_services=>file_open_dialog
changing
file_table = lt_file "Table Holding Selected Files
User_action = L_user_action
rc = L_rc.
IF l_user_action = Cl_gui_frontend_services=>action_ok. "Action_cancel.
READ TABLE lt_file into Lx_file INDEX 1.
IF SY-SUBRC = 0.
L_filename = Lx_file-filename.
ELSE.
CLEAR L_filename.
ENDIF.
ELSE.
CLEAR L_filename.
ENDIF.


1, the file upload to the FTP reference program zfg_mm052d
Call FUNCTION ' Z_ftp_upload '
Exporting
L_data = Wa_data
EXCEPTIONS
Connecterror = 1
OTHERS = 2.
2. File download from FTP reference program zfg_mm052d
Call FUNCTION ' Z_ftp_download '
Exporting
L_data = Wa_data
TABLES
T_dir = l_dir[]
EXCEPTIONS
Connecterror = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

3, the picture is converted into the encoding to upload to the Ztpicture table

 DATA:l_url            TYPE char256,
         l_filename       TYPE string,
*         l_path           type STRING,
        l_length         TYPE I,
        lt_file            TYPE filetable,
        lx_file            like line of Lt_file,
        l_rc              TYPE I,
        l_ user_action    type I.
  DATA:L_PICID type indx_srtfd.

REFRESH F_it_pic_data_out.


* *. Upload the file
IF L_filename is not INITIAL.
Call METHOD Cl_gui_frontend_services=>gui_upload
Exporting
filename = l_filename "Name of File
filetype = ' BIN ' "Here is" Binary type "
Importing
Filelength = l_length "File length
changing
Data_tab = f_it_pic_data_out[] "Transfer table for file contents
EXCEPTIONS
OTHERS = 19.
IF SY-SUBRC NE 0.
MESSAGE e001 (xx) with ' Upload the file Error '.
ENDIF.
ENDIF.


4, download the picture reference program from the Table ztpicture Garment Inquiry Form zfc_mm005b

FORM load_picture_from_db USING f_key_in "f_key_in is the notification number is the serial numbers
changing F_it_pic_data_out TYPE Ty_t_pic_data.
Data:l_picid TYPE indx_srtfd.
REFRESH F_it_pic_data_out.
Concatenate ' zcostacch ' f_key_in into L_picid.
IMPORT pic_data = f_it_pic_data_out from DATABASE ztpicture (mm) ID l_picid. " Get the code in the table
IF SY-SUBRC <> 0.
REFRESH F_it_pic_data_out.
ENDIF.
EndForm. "load_picture_from_db

Data:l_length TYPE I. "Both methods can download image encoding to local ZT
Call METHOD Cl_gui_frontend_services=>gui_download
Exporting
filename = ' C:\Documents and settings\administrator\ desktop \1.jpg ' "Name of File
filetype = ' BIN ' "Here is" Binary type "
Importing
Filelength = l_length "File length
changing
Data_tab = it_pic_data[] "Transfer table for file contents
EXCEPTIONS
OTHERS = 19.

Call FUNCTION ' Gui_download '
Exporting
* Bin_filesize =
filename = ' C:\Documents and settings\administrator\ desktop \1.jpg '
filetype = ' JPG '
TABLES
Data_tab = it_pic_data[]
EXCEPTIONS
File_write_error = 1
No_batch = 2
Gui_refuse_filetransfer = 3
Invalid_type = 4
No_authority = 5
Unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
Header_too_long = 10
Dp_error_create = 11
Dp_error_send = 12
Dp_error_write = 13
Unknown_dp_error = 14
Access_denied = 15
Dp_out_of_memory = 16
Disk_full = 17
Dp_timeout = 18
File_not_found = 19
Dataprovider_exception = 20
Control_flush_error = 21
OTHERS = 22.

FTP Upload Download | Image upload Download

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.