1
urbanspacema
two uploads one form

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"], nullnull);

        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"], nullnull);
        
        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?

2
ghia
Re: two uploads one form
  • 2009/8/15 15:03

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


It should be possible to upload several files at once with one form. A practical limit (depending on file size) is 4.

I must say your code differs from the example code given in the header of /class/uploader.php

3
Mazar
Re: two uploads one form
  • 2009/8/15 15:57

  • Mazar

  • Not too shy to talk

  • Posts: 191

  • Since: 2009/1/4 0


I remember once i asked a similar question to use uploader class for multiple uploads i was told the class allows only single upload at a time.

4
ghia
Re: two uploads one form
  • 2009/8/15 16:06

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


XcGal has a form for uploading four files (not using XOOPS core). Search for _FILES

5
urbanspacema
Re: two uploads one form

tnx ghia

Login

Who's Online

216 user(s) are online (80 user(s) are browsing Support Forums)


Members: 0


Guests: 216


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits