Strange behavior due to different uploaded file types

A place for users and developers of the Xataface to discuss and receive support.

Strange behavior due to different uploaded file types

Postby conkhikho » Wed Nov 25, 2009 9:24 pm

I don't know how to concisely explain the problem, so the subject is probably unclear.

What I want to achieve is: The user can upload a file (either images with extensions jpg or bmp, or video clips with extension f4v or flv), and upon uploading, the file is processed and organized to its appropriate folder (not its default).

How I am doing this: I have a widget:type = file for a field called AFilename (in which the user can browse to the file). This field is eventually set to hold the file name alone with no extension. Temporary folder to store the file is defined in savepath and url. There is another field called 'type' for the user to indicate whether this is an image or a video. Here's the rough code

Code: Select all
<php>

class tables_assets {
     
     function beforeInsert(&$record){

          if ( $record->valueChanged('AFilename') ){

            $fieldDef =& $record->_table->getField('AFilename');
            
            // get extension based on .
            // get filename based on extension
            $filen = $record->val('AFilename');
            $filename = basename($filen); // filename.ext
            $extension = end(explode('.', $filename)); // ext
            $filename = basename($filen, ".".$extension); // filename
      
            $newFilename = $filename;

            if ($record->val('type') == 1){ // image
               // build the new file path and rename the image to that file path
               .....
            }
            else if ($record->val('type') == 2) { // video
               // build the new file path and rename the video to that file path
               .......
            }

            // 2. set the file name
            $record->setValue('AFilename', $newFilename);
          }
         
     }

}

?>


Now the problem is: It works fine for type 1 (image), but when i try uploading a type 2 file (video), xataface returns an error saying
"Errors
* Some errors occurred while processing this form:
o AFilename is a required field.
"

I really have no clue why this happens. Any suggestion is greatly appreciated. Thanks a lot folks.

Tim
conkhikho
 
Posts: 11
Joined: Wed Oct 07, 2009 5:57 pm

Postby shannah » Tue Dec 01, 2009 1:47 pm

My guess is this is related to file size. Check your PHP settings for max upload size and max post size. If you upload a file that exceeds this size then the file won't be passed through and your "required" validator for the field will fail.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby conkhikho » Wed Dec 02, 2009 12:11 pm

Thank you very much Steve. Yeah, it's the file size limit problem... Once I set a higher limit, the problem is gone.
conkhikho
 
Posts: 11
Joined: Wed Oct 07, 2009 5:57 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 21 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved