Skip to: site menu |main content

Welcome to my personal site. If You have any question or suggestion please feel free to contact me from contact page.

Advertisements

Contact me to place your Ads Here..

Powered by Drupal, an open source content management system

Syndicate

Syndicate content

file upload

File Save Upload for Drupal 6 users Accessing $_FILES is not prefered in drupal

In drupal 6 you can use file_save_upload() function for saving your uploaded files.Instead of mannually accessing $_FILES drupal standard is prefered.

<?php
file_save_upload
($source, $validators = array(), $dest = FALSE, $replace = FILE_EXISTS_RENAME);
?>

For making your custom form to work for file upload you need to set Enctype for your form in following manner:-

<?php
$form
['#attributes'] = array('enctype' => "multipart/form-data");
?>

File Uploading Example Code for PHP

PHP function move_uploaded_file — Moves an uploaded file to a new location. This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination .

This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system. This function returns TRUE on success, or FALSE on failure.
Syntax

Syndicate content

Back to top