Ciao a tutti, è possibile integrare una funzione PHP già esistente con una funzione CGI?
La funzione PHP si occupa di gestire l'upload di file tramite apposito form ed esegue i seguenti controlli:
-Massima dimensione del file consentita
-Archiviare i file caricati nella cartella
-Assegnare un id unico/nome, ai file caricati
-Controllare l'estensione del file
Però non esite la funzione che serve per controllare lo stato di avanzamento del caricamento del file
Sul server dove è caricata la pagina non è possibile abilitare l'estensione APC di PHP
Questa è la funzione nel file PHP:
Vorrei integrarla con XUploadcodice:private function uploadConfigurableFile($fieldOptions, $file) { if (!is_array($fieldOptions) || !is_array($file) || empty($file['name'])) { return false; } $extension = GetFileExtension($file['name']); $allowedExtensions = array_map('trim', explode(',', $fieldOptions['fieldfiletype'])); $allowedExtensions = array_map('isc_strtolower', $allowedExtensions); if ($fieldOptions['fieldfiletype'] && !in_array(isc_strtolower($extension), $allowedExtensions)) { throw new ISC_QUOTE_EXCEPTION(sprintf(GetLang('InvalidFileType'), isc_html_escape($fieldOptions['fieldfiletype']))); } // Check that the maximum size is not exceeded if ($fieldOptions['fieldfilesize'] > 0 && $file['size'] > $fieldOptions['fieldfilesize']*1024) { throw new ISC_QUOTE_EXCEPTION(sprintf(GetLang('InvalidFileSize'), $fieldOptions['fieldfilesize'])); } // Store the uploaded files in our configured products directory $uploadDirectory = ISC_BASE_PATH.'/'.GetConfig('ImageDirectory').'/configured_products_tmp/'; if (empty($file['existingPath'])) { /** * @todo Implement temporary sharing/storage location with automatic pruning. */ $fileName = $fieldOptions['productfieldid'].'_'.md5(uniqid()).'.'.$extension; if (!move_uploaded_file($file['tmp_name'], $uploadDirectory.$fileName)) { throw new ISC_QUOTE_EXCEPTION(getLang('CanNotUploadFile')); } } else { $fileName = basename($file['existingPath']); } // If we've just uploaded an image, we need to perform a bit of additional validation // to ensure it's not someone uploading bogus images. $imageExtensions = array( 'gif', 'png', 'jpg', 'jpeg', 'jpe', 'tiff', 'bmp' ); if (in_array($extension, $imageExtensions)) { // Check a list of known MIME types to establish the type of image we're uploading switch(isc_strtolower($file['type'])) { case 'image/gif': $imageType = IMAGETYPE_GIF; break; case 'image/jpg': case 'image/x-jpeg': case 'image/x-jpg': case 'image/jpeg': case 'image/pjpeg': case 'image/jpg': $imageType = IMAGETYPE_JPEG; break; case 'image/png': case 'image/x-png': $imageType = IMAGETYPE_PNG; break; case 'image/bmp': $imageType = IMAGETYPE_BMP; break; case 'image/tiff': $imageType = IMAGETYPE_TIFF_II; break; default: $imageType = 0; } $imageDimensions = getimagesize($uploadDirectory.$fileName); if (!is_array($imageDimensions) || $imageDimensions[2] != $imageType) { @unlink($uploadDirectory.$fileName); throw new ISC_QUOTE_EXCEPTION(GetLang('InvalidImageFile')); return false; } } return $fileName; }
Nel file di configurazione di XUplolad ci sono i seguenti parametri da impostare, ma non ho idea su come fare
È possibile integrare i 2 file?codice:package XUploadConfig; BEGIN { use Exporter; @XUploadConfig::ISA = qw( Exporter ); @XUploadConfig::EXPORT = qw( $c ); } our $c= { # Directory for temporary using files temp_dir => '/var/www/cgi-bin/temp', # Directory for uploaded files target_dir => '/var/www/cgi-bin/uploads', # Allowed file extensions delimited with '|' #ext_allowed => 'jpg|jpeg|gif|png|rar|zip|mp3|avi|txt|csv', ext_allowed => '.*', # URL to send all input values from upload page url_post => 'http://site.com/post.php', # The link to redirect after complete upload # This setting can be submitted from HTML form, then it will have priority # url_post have priority over redirect redirect_link => '', # Max length of uploaded filenames (without ext). Longer filenames will be cuted. max_name_length => 64, # Type of behavior when uploaded file already exist on disc. Available 3 modes: Rewrite/Rename/Warn copy_mode => 'Rename', # Maximum total upload size in Mbytes max_upload_size => 100, # Time to keep temp upload files on server, sec (24 hours = 86400 seconds) temp_files_lifetime => 86400, }; 1;
Grazie in anticipo

Rispondi quotando