Since a few days the captcha image doesn't show up anymore.
I when i try to reach the captcha.php the file gives me an error:
Fatal error: Class 't3lib_div' not found in /typo3conf/localconf.php on line 10
When I lookup the localconf.php file, the first 20 lines look like this:
<?php
$TYPO3_CONF_VARS['SYS']['sitename'] = 'New TYPO3 site';
// Default password is "joh316" :
$TYPO3_CONF_VARS['BE']['installToolPassword'] = 'bacb98acf97e0b6112b1d1b650b84971';
$TYPO3_CONF_VARS['EXT']['extList'] = 'tsconfig_help,context_help,extra_page_cm_options,impexp,sys_note,tstemplate,tstemplate_ceditor,tstemplate_info,tstemplate_objbrowser,tstemplate_analyzer,func_wizards,wizard_crpages,wizard_sortpages,lowlevel,install,belog,beuser,aboutmodules,setup,taskcenter,info_pagetsconfig,viewpage,rtehtmlarea,css_styled_content,t3skin';
$typo_db_extTableDef_script = 'extTables.php';
// MAX FILE SIZE
$TYPO3_CONF_VARS['BE']['maxFileSize'] = '100000';
t3lib_div::loadTCA('tt_content');
// This changes the upload limit for image elements
$TCA['tt_content']['columns']['image']['config']['max_size'] = 100000;
// This changes the upload limit for media elements
$TCA['tt_content']['columns']['media']['config']['max_size'] = 100000;
// This changes the upload limit for multimedia elements
$TCA['tt_content']['columns']['multimedia']['config']['max_size'] = 100000;
Does anybody has an idea why I get this error?
The best would be that this settings below would be in ext_tables.php file of some extension.
But if you don't have any special ext for that then you can put that into typo3conf/extTables.php file. After that the error about t3lib_div not found should be gone.
// MAX FILE SIZE
$TYPO3_CONF_VARS['BE']['maxFileSize'] = '100000';
t3lib_div::loadTCA('tt_content');
// This changes the upload limit for image elements
$TCA['tt_content']['columns']['image']['config']['max_size'] = 100000;
// This changes the upload limit for media elements
$TCA['tt_content']['columns']['media']['config']['max_size'] = 100000;
// This changes the upload limit for multimedia elements
$TCA['tt_content']['columns']['multimedia']['config']['max_size'] = 100000;
Related
When I try to post my form ( using ajax ) I got error
Notice: Undefined index: prepared_object
And this is the portion of my function which takes that action
public function saveASpotAction(Request $request){
$place_id = isset($_POST['place_id'])&&!empty($_POST['place_id'])?$_POST['place_id']:0;
$prepared_object_decoded = json_decode($_POST['prepared_object']);
if($prepared_object_decoded->add_method=='duplicate_travel_card')
{
$save_response_array = $this->duplicateTravelcard();
}
else if($place_id)
{
$save_response_array = $this->saveASpotOnEdit();
}
else
{
$save_response_array = $this->saveASpotOnNew();
}
In the post request the variable have a value, and still it shows the error.
But it work fine when there is no images or a very images uploaded with the request and that feels strange to me.
At last I found the solution, Its becuause of maximum post size in server settings, It was 20M, And when the uploaded file size is get over that allocated size the variabled will not get on server, I increased it to 1024M, Not Its working ..
I am developing a text collection engine using fwrite() to write text but I want to put a file size cap of 1.5 mb on the writing process so if the file is larger that 1.5mb it will start writing a new file from where it left off and so on until it writes the contents of the source file into multiple files. I have Google-searched but many of the tutorials and examples are too complex for me because I am a novice programmer. The code below is inside a for loop which fetches the text ($RemoveTwo). It does not work as I need. Any help would be appreciated.
switch ($FileSizeCounter) {
case ($FileSizeCounter> 1500000):
$myFile2 = 'C:\TextCollector/'.'FilenameA'.'.txt';
$fh2 = fopen($myFile2, 'a') or die("can't open file");
fwrite($fh2, $RemoveTwo);
fclose($fh2);
break;
case ($FileSizeCounter> 3000000):
$myFile3 = 'C:\TextCollector/'.'FilenameB'.'.txt';
$fh3 = fopen($myFile3, 'a') or die("can't open file");
fwrite($fh3, $RemoveTwo);
fclose($fh3);
break;
default:
echo "continue and continue until it stops by the user";
}
Try doing something like this. You need to read from a source then write piece by piece all the while checking for end of file from the source. When you compare the max and buffer values, if they are true, then close the current file and open a new one with an auto-incremented numeric:
/*
** #param $filename [string] This is the source
** #param $toFile [string] This is the base name for the destination file & path
** #param $chunk [num] This is the max file size based on MB so 1.5 is 1.5MB
*/
function breakDownFile($filename,$toFile,$chunk = 1)
{
// Take the MB value and convert it into KB
$chunk = ($chunk*1024);
// Get the file size of the source, divide by kb
$length = filesize($filename)/1024;
// Put a max in bits
$max = $chunk*1000;
// Start value for naming the files incrementally
$i = 1;
// Open *for reading* the source file
$r = fopen($filename,'r');
// Create a new file for writing, use the increment value
$w = fopen($toFile.$i.'.txt','w');
// Loop through the file as long as the file is readable
while(!feof($r)) {
// Read file but only to the max file size value set
$buffer = fread($r, $max);
// Write to disk using buffer as a guide
fwrite($w, $buffer);
// Check the bit size of the buffer to see if it's
// same or larger than limit
if(strlen($buffer) >= $max) {
// Close the file
fclose($w);
// Add 1 to our $i file
$i++;
// Start a new file with the new name
$w = fopen($toFile.$i.'.txt','w');
}
}
// When done the loop, close the writeable file
fclose($w);
// When done loop close readable
fclose($r);
}
To use:
breakDownFile(__DIR__.'/test.txt',__DIR__.'/tofile',1.5);
I have a little Problem. I have a Script, that allows people to upload files in a multiple select input. Those input fields are submitted via HTTPXML Request. But i tried to select 98 Pictures with about 900MB - They were uploaded and the ZIP Script finished without any error. But when I want to download the File it is only 200 MB and only 20 Pictures are in the ZIP. I increased the maximum execution time on the server - but the script seems to run for 24 seconds only. I increased the PHP Memory Limit to 2 GB - The Server has enough Ram as well. The Maximum File Size is about 2GB the Maximum Upload Size too.
Here The Script:
$zip = new ZipArchive();
$res = $zip->open(__DIR__."/../files/".$filename, ZIPARCHIVE::CREATE);
if($res){
for($i = 0; $i < count($_FILES['datei']['name']); $i++){
move_uploaded_file($_FILES['datei']['tmp_name'][$i], __DIR__.'/../temp/'.$_FILES['datei']['name'][$i]);
if(file_exists(__DIR__.'/../temp/'.$_FILES['datei']['name'][$i]) && is_readable(__DIR__.'/../temp/'.$_FILES['datei']['name'][$i])){
$zip->addFile(__DIR__.'/../temp/'.$_FILES['datei']['name'][$i], $_FILES['datei']['name'][$i]);
}else{
$status['uploaded_file'] = 500;
}
}
$res_close = $zip->close();
if($res_close){
$status['uploaded_file'] = 200;
}
for($i = 0; $i < count($_FILES['datei']['name']); $i++){
unlink(__DIR__.'/../temp/'.$_FILES['datei']['name'][$i]);
}
}else{
die($res);
$status['uploaded_file'] = 500;
}
The Script basically moves all the TEMP Files to another TEMP Folder. From Those TEMP Folder they are being Zipped to a file folder. Afterwords the Files from the TEMP Folder are going to be deleted.
Is there anything stupid I am doing wrong? Or is there another limitation I didnt see?
Thanks for Help
I want to get the page numbers of ppt files.
My Code:
$filename = "aaa.ppt";
$word = new COM("Powerpoint.Application");
$word->PresentationDocument->Open($filename);
$wdStatisticPages = 2; // Value that corresponds to the Page count in the Statistics
echo $word->ActivePresentation->SlideParts->Count($wdStatisticPages);
$word->ActivePresentation->Close();
$word->Quit();
But it gives error:
Fatal error: Uncaught exception 'com_exception' with message 'Unable
to lookup `PresentationDocument': Unknown name. '
This is kind of issue is due to the following factors.
PHP.ini settings
File/ Folder Permission
allow open is not enabled in the server
allowed upload size
I got the answer, thanks Suyog for your efforts.
$filename = "aaa.ppt";
$power = new COM("Powerpoint.Application");
$power->visible = True;
$power->Presentations->Open(realpath($filename));
echo $power->ActivePresentation->Slides->Count;
//$word->ActiveDocument->PrintOut();
$power->ActivePresentation->Close();
$power->Quit();
I'm looking to upload multiple files to a folder once all of the conditions are met successfully. I'm allowing the user to choose how many files they'd like to upload, however am receiving this error from the script:
Notice: Undefined offset: 1 in C:\xampp\htdocs\FreeCheese\news_parse.php on line 54
Note:
The number following 'Undefined offset:', in this case is set to '1'. When I chose to insert more file fields into the page this number becomes whatever the number of current file fields are being read by the PHP.
EG: I have three file fields, the error would then become:
Notice: Undefined offset: 3 in C:\xampp\htdocs\FreeCheese\news_parse.php on line 54
If I do select three files to upload, all of them are being correctly inserted into the folder, so I have no idea why I am being given an error when it is functioning as it should.
If anyone could help me fix this error then it'd be much appreciated.
Thanks in advance, Rich
Here is my code:
// Set the array object to 0 when entering the loop.
$i = 0;
while ($_FILES['upload1']['tmp_name'][$i]) {
$imgName1 = preg_replace("#[^a-z0-9.]#i", "", $_FILES['upload1']['name'][$i]);
// Applies a unique number before the file name to prevent files from overwriting.
$imgName1 = mt_rand(100000, 999999).$imgName1;
// Moves the image into the images/ folder
move_uploaded_file($imgTmp1[$i], "images/$imgName1");
// Sets the next array object in the loop to 1 etc etc
$i ++;
}
If there are 5 files, then $_FILES['upload1']['tmp_name'][5] won't exist, so the while condition crashes (it doesn't return false !)...
You have to check count($_FILES['upload1']['tmp_name']) !
$nbFiles = count($_FILES['upload1']['tmp_name']);
while ($i < $nbFiles) {
[...your code...]
$i++;
}
You should also use a for loop, since it is made for what you need :
$nbFiles = count($_FILES['upload1']['tmp_name']);
for ($i=0; $i < $nbFiles; $i++) {
[...your code...]
}