This is the code that i am using to loop through directory and get the images from it.
PHP Code:
if ($location) {
$path = $location;
$dir_handle = @opendir($path) or die("Unable to open folder");
$filecount = 0;
$file_result = Array();
while (false !== ($file = readdir($dir_handle))) {
if (ereg("(.*)\.(jpg|bmp|jpeg|png|gif)", $file))
{
$fileid = "file".$filecount;
$_FILES[$fileid]['name'] = $file;
//array_push($_FILES,$file);
$filecount++;
}
}
closedir($dir_handle);
This is the code what i am using to send each file to the function.
PHP Code:
for($f=1;$f<6;$f++)
{
$fileid = "file".$f;
if($_FILES[$fileid]['name'] != "")
{
$file_result[$fileid] = $group->group_media_upload($fileid, $groupalbum_info['groupalbum_id'], $space_left);
}
}
PHP Code:
function group_media_upload($file_name, $groupalbum_id, &$space_left)
{
global $database, $url, $user;
// SET KEY VARIABLES
$file_maxsize = $this->groupowner_level_info['level_group_album_maxsize'];
$file_exts = explode(",", str_replace(" ", "", strtolower($this->groupowner_level_info['level_group_album_exts'])));
$file_types = explode(",", str_replace(" ", "", strtolower($this->groupowner_level_info['level_group_album_mimes'])));
$file_maxwidth = $this->groupowner_level_info['level_group_album_width'];
$file_maxheight = $this->groupowner_level_info['level_group_album_height'];
$new_media = new se_upload();
$new_media->new_upload($file_name, $file_maxsize, $file_exts, $file_types, $file_maxwidth, $file_maxheight);
..... .... ..... .....
PHP Code:
function new_upload($file, $file_maxsize, $file_exts, $file_types, $file_maxwidth = "", $file_maxheight = "")
{
// GET FILE VARS
$this->file_name = $_FILES[$file]['name'];
$this->file_type = strtolower($_FILES[$file]['type']);
$this->file_size = $_FILES[$file]['size'];
$this->file_tempname = $_FILES[$file]['tmp_name'];
$this->file_error = $_FILES[$file]['error'];
$this->file_ext = strtolower(str_replace(".", "", strrchr($this->file_name, ".")));
.... ... .... ..
The upload page for the users who are asked to upload files uses form post. just like any other upload form. But since i am trying to do that from the php server side i am looking for a way to correctly populate the $_FILES array with the data that i wanna send to the upload function of the CMS because that function uses $_FILES array inorder to process the uploaded files.
Can you help with this?
thanks