1
Hello all
I'm coming to develop a module but i have an issue with file upload.
My form has 2 field for upload file, one for image and one for a file (mp3/wma in my case)
the code is this (the module was generated from TDMCreate)
//Form podcast_image
include_once XOOPS_ROOT_PATH."/class/uploader.php";
$uploaddir_podcast_image = XOOPS_ROOT_PATH."/uploads/podcast/podcast/podcast_image/";
$uploader_podcast_image = new XoopsMediaUploader($uploaddir_podcast_image, $xoopsModuleConfig["podcast_image_mimetypes"], $xoopsModuleConfig["podcast_image_size"], null, null);
if ($uploader_podcast_image->fetchMedia("podcast_image")) {
$uploader_podcast_image->setPrefix("podcast_image_") ;
$uploader_podcast_image->fetchMedia("podcast_image");
if (!$uploader_podcast_image->upload()) {
$errors = $uploader_podcast_image->getErrors();
redirect_header("javascript:history.go(-1)",3, $errors);
} else {
$obj->setVar("podcast_image", $uploader_podcast_image->getSavedFileName());
}
} else {
$obj->setVar("podcast_image", $_REQUEST["podcast_image"]);
}
//Form podcast_file
include_once XOOPS_ROOT_PATH."/class/uploader.php";
$uploaddir_podcast_file = XOOPS_ROOT_PATH."/uploads/podcast/podcast/podcast_file/";
$uploader_podcast_file = new XoopsMediaUploader($uploaddir_podcast_file, $xoopsModuleConfig["podcast_file_mimetypes"], $xoopsModuleConfig["podcast_file_size"], null, null);
if ($uploader_podcast_file->fetchMedia("podcast_file")) {
$uploader_podcast_file->setPrefix("podcast_file_") ;
$uploader_podcast_file->fetchMedia("podcast_file");
if (!$uploader_podcast_file->upload()) {
$errors = $uploader_podcast_file->getErrors();
redirect_header("javascript:history.go(-1)",3, $errors);
} else {
//$obj->setVar("podcast_file", $uploader_podcast_file->getSavedFileName());
$obj->setVar("podcast_file", $uploader_podcast_file->getSavedFileName());
}
}
the image was uploaded coreectly and his name insert in the database.
the file is not loaded.
and get any error message.
can be the upload XOOPS class does not allow two upload from the same form?