Tuto WEBDEV 25
122 Part 3: Intranet site with data 4. Let’s study this code: • UploadCopyFile is used to save on the server the file uploaded by the user. In our case, the file is copied into the data directory (returned by fDataDir ). The file name is kept. • Then, the path of uploaded image is stored in a global variable named gsImagePath . Remark Why use a global variable? A global variable is required here because the image path will be used in the code of "Validate" button, to save the new image in the data file. See the appendices for more details about the use conditions of local and global variables. • fSep allows you to retrieve the separator that will be used on the operating system of server ("\" for Windows, "/" for Linux). Therefore, your site is independent of the server where it is installed! • Then, the uploaded image is displayed in the IMG_Visual Image control. 5. When typing and saving the code, the gsImagePath variable is displayed in red and a compilation error occurs in the error pane: "‘gsImagePath’ identifier unknown or inaccessible". Indeed, this global variable was not declared. 6. To declare the global variable: • Display the "Global declarations" event of the page (for example, in the Code editor, go to the "Code" pane, and and select "Global declarations" in the combo box that lists all the events). • Type the following code after the procedure declaration: gsImagePath is string
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==