Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
isMediaFile arguments?
musiccreatures



Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 11/23/09 12:22 
I would like to be able to give users the ability to upload images with their classified ads. In order to do so, I would need to make sure that the image format is an allowed format for the users quota. It looks like the isMediaFile() function is the answer. The only issue is that I'm not sure I am using the proper arguments.

    bool isMediaFile (string $file, [string $type = 'audio'], array &$_quot)



I tried to place the code below, during the error checking of the upload form.
$_post['meter_file_1'] is the File Upload form element


Code

//  Error checking:  Does the users quota allow this file format?
if (!isMediaFile($_post['meter_file_1'],'image',$_user['quota_image_formats'])) {
// do something!!!
}


Any suggestions?

Thanks,
Tim

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/23/09 15:43 
Try just $_user for the last argument.

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
musiccreatures



Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 11/23/09 17:37 
Thanks for the reply Kyle. I tried your suggestion, and it didn't work. Basically I am just trying to get the file uploading to work. With that in mind, I added 2 modes to my form controller, for testing purposes only. What I hoped would happen when this script is ran is:

ON mode=upload:
Display a simple form, with progress meter, that asks for the file to upload.

On the forms submit(mode=upload_done), the script should Iterate through the $_post['meter_file_1'] image array and echo the image attributes. (Name, type, tmp_name, error, & size) Then test the image to see if the file type is allowed by the users quota.

Everything seems to work great, until I get to the, 'Something went terribly wrong!'

Here is a snippet of form controller, Maybe you see something wrong?


Code

switch ($_post['mode']) {
  case 'upload':
    jmHtmlBegin('File Upload');
    $_args = array(
      'mode' => 'upload_done'
    );
    jrProgressFormBegin('mcClassifiedAds.php',$_args);
    jmSpanCell('File Upload','This is the Help',30,'html_modify.png');
    jmInput('Select a File',"meter_file_1",'file');
    jrProgressBarHtml();
    jrFormSubmit('Upload File','undo changes',false,'admin.php',false,true,'media');
    jmEndForm();
    jmBodyEnd();
    jmHtmlEnd();

    break;
    exit;

  case 'upload_done':
    foreach($_post['meter_file_1'] as $key => $value) {
      echo "-post['{$key}'] = '{$value}'<br/>";
    }

    echo "The files extension is: ". getExt($_post['meter_file_1']['name']) ."<br/>";
      
    if (isMediaFile($_post['meter_file_1'],"image", $_user)) {
      jrMediaGetFile("mcClassifiedAds","meter_file_1",'11',$_user['band_id']);
      echo "saved?";
    } else {
      echo "something went terribly wrong!";
    }

    break;
    exit;
}



Any help would be greatly appreciated.

Thanks,
Tim

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/23/09 17:51 
What do you have that field set to for this quota? And what image extension are you using?


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
musiccreatures



Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 11/23/09 18:15 
Thanks again for your help.

Not sure what you mean by:

Quote:
What do you have that field set to for this quota?


The image extensions:
$_user['quota_image_formats'] = 'gif,png,jpg,jpeg,jpe'

And I am trying to upload: Les Paul GoldTop1.JPG

I wonder if it is because the image I am attempting to upload has spaces in the filename, or that the JPG is in caps?

Back to top
musiccreatures



Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 11/23/09 18:26 
Thanks for the help, Kyle. That was the issue. I changed the code, just a bit:


Code

if (isMediaFile(strtolower($_post['meter_file_1']['name']),"image", $_user)) {
  jrMediaGetFile("mcClassifiedAds","meter_file_1",'14',$_user['band_id']);
  echo "saved?";
} else {
  echo "something went terribly wrong!";
}


And Now I see the image, in the users media directory.

Do you know what function to use, to make sure that the user hasn't exceeded their disk space?

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 11/23/09 23:21 
I think jrMediaGetFile will tell you that or not.

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.