Jump to content
  • 0

How to Limit File Size and Restrict File types from Upload


Question

5 answers to this question

Recommended Posts

  • 0
Posted

if you want to use the UPLOAD class you can do like this

a sample how to like this :

// Load the pload components
Loader::loadComponents($this, ["Upload"]);
// Set the alloweded file types
$this->Upload->setAllowedMimeTypes(['gif','png','pdf']);
// Set the maximum file size
$this->Upload->setMaxFileSize(2048); // size in bytes
$this->Upload->setFiles($files, false); // the files list to upload
$this->Upload->setUploadPath("/home/user/upload_directory/"); // the upload path directory
// Will not overwrite existing file
// And we will support the uploaded files are in $files['data']
$this->Upload->writeFile("data", false);

// check if the upload was successfully 
if (!($errors = $this->Upload->errors())) {
	$this->Input->setErrors($errors);
    return;
}

 

 

  • 0
Posted

@Blesta Addons

 

1)  - Exactly which folder and file do I place this code ?

 

2) - And where within the file ( top, bottom, middle ) ?
 

Quote

// Load the pload components
Loader::loadComponents($this, ["Upload"]);
// Set the alloweded file types
$this->Upload->setAllowedMimeTypes(['gif','png','pdf']);
// Set the maximum file size
$this->Upload->setMaxFileSize(2048); // size in bytes
$this->Upload->setFiles($files, false); // the files list to upload
$this->Upload->setUploadPath("/home/user/upload_directory/"); // the upload path directory
// Will not overwrite existing file
// And we will support the uploaded files are in $files['data']
$this->Upload->writeFile("data", false);

// check if the upload was successfully 
if (!($errors = $this->Upload->errors())) {
	$this->Input->setErrors($errors);
    return;
}

 

  • 0
Posted
6 hours ago, turner2f said:

@Blesta Addons

 

1)  - Exactly which folder and file do I place this code ?

 

2) - And where within the file ( top, bottom, middle ) ?
 

 

First where you want to use it ?

you need to add this code in your plugin/module that your  are coding it .

  • 0
Posted

I am needing this for the "Support Manager" function.

For when people are submitting their support tickets.

 

1)  - Exactly which folder and file do I place this code ?

2) - And where within the file ( top, bottom, middle ) ?

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...