1 / 6

File Uploads

File Uploads. The Form tag. Set the method to “post” The form attribute enctype ="multipart/form-data” must be in the opening form tag Before the file field you must have a hidden field with a name of MAX_FILE_SIZE and the max size of the file in bytes

alaura
Download Presentation

File Uploads

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. File Uploads

  2. The Form tag • Set the method to “post” • The form attribute enctype="multipart/form-data” must be in the opening form tag • Before the file field you must have a hidden field with a name of MAX_FILE_SIZE and the max size of the file in bytes • The file field displays differently in different browsers.

  3. Folder Permissions • The folder you are adding images to must be writable by the web server. • The web server runs as the user apache and is a different user then you are. • You must set the permissions to 777 or rwxrwxrwx on the folder you are going to save in. In this case the images folder. • Use FileZilla or Cyberduck to set the permissions and NOT the Mac interface.

  4. Global Variables • The file is accessed through the global variable $_FILES • If the file form element is called userfile then the file is referenced with $_FILES[“userfile”] • It will be a multi-dimensional array with four sub keys of name, temp_name, size and type.

  5. Simple move • You can use the PHP command move_uploaded_file to transfer the temp file to its new location. • If the temp file is not transferred before the end of the script executing the temp file is automatically deleted.

  6. GD • GD is an extension of PHP that allows you to modify images. • It has basic functionality as compared to Imagemagick.

More Related