would
get me the name of the uploaded file?PHP Code:
$file_name = $_FILES[$key]['name'];
would
get me the name of the uploaded file?PHP Code:
$file_name = $_FILES[$key]['name'];
my question is, if I add something to the beggining of $file_name do i need to re add the extension or would it still retain the extension?PHP Code:
$name_pre = 'test';
$file_name = $_FILES[$key]['name'];
$file_ext = basename($_FILES[$key]['name']);
$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
would that work, or would I have to put the extension back on the end?PHP Code:
$filename = $name_pre . $file_name;
this doesn't work Warning: no file uploaded.
PHP Code:
$att_array = array();
foreach($_FILES as $key => $file) {
$folderid = 'test';
$imagefolder = DIR_FS_UPLOADS;
$folderPath = $imagefolder . $folderid;
$name_pre = 'test';
$file_name = ($_FILES[$key]['name']);
$file_ext = basename($_FILES[$key]['name']);
$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
$filename = 'test';
if (zen_not_null($_FILES[$key]['tmp_name'])) {
$exist = is_dir($folderPath);
if(!$exist) {
mkdir("$folderPath");
chmod("$folderPath", 0755);
}
$upload = new upload;
$upload->set_file = $key;
$upload->set_destination = $folderPath;
if ($upload->parse() == true) {
$upload->set_filename = $filename;
$att_array[] = array('file' => $upload->destination . $upload->filename, 'name' => $upload->filename);
$upload->save();
} else {
//die('could not manage uploads');
}
}
}
it is uploading, but it is uploading to the root directory
figured it out... silly me, will post new code shortly
to enable file uploading from ios devices that name all files as image.jpg, i've set the image rename to be microtime as i was worried rand might clash, and then I would need a check for if the file already existed, this method seemed simpler.
PHP Code:
$att_array = array();
foreach($_FILES as $key => $file) {
$folderid = 'test';
$imagefolder = DIR_FS_UPLOADS;
$folderPath = $imagefolder . $folderid;
$name_pre = microtime();
$file_name = ($_FILES[$key]['name']);
$file_ext = basename($_FILES[$key]['name']);
$ext = substr($file_ext, strrpos($file_ext, '.') + 1);
$filename = ($name_pre . '.' . $ext);
if (zen_not_null($_FILES[$key]['tmp_name'])) {
$exist = is_dir($folderPath);
if(!$exist) {
mkdir("$folderPath");
chmod("$folderPath", 0755);
}
$upload = new upload;
$upload->set_file($key);
$upload->set_destination($folderPath);
if ($upload->parse() == true) {
$upload->set_filename($filename);
$upload->save();
$att_array[] = array('file' => $upload->destination . $upload->filename, 'name' => $upload->filename);
} else {
//die('could not manage uploads');
}
}
}
Wow, I realize it's been years since anyone has commented on this thread but I happen to come across it while searching for a way to create a form that will allow multiple images to be uploaded. Is this the latest and greatest thread for working to resolve this puzzle? Any input would be appreciated. I am currently using 1.5.7c.
Thanks in advance.
Bookmarks