I use at the moment joomla 1.14
I did it so resolved, but it is still not quite well.
I have added this function
Code:
function randomgenerator($aantaltekens)
{
$kleineletters = range('a','z');
$groteletters = range('A','Z');
$cijfers = range(0,9);
$karakters = array_merge($kleineletters, $groteletters, $cijfers);
$aantal = count($karakters)-1;
$random = null;
for($i=0; $i < $aantaltekens; $i++)
{
$random .= $karakters[mt_rand(0, $aantal)];
}
return $random;
}
I the function savePost() i have add this, and this works well.
Code:
.
.
.
$random = randomgenerator(5);
.
.
.
$newcookbook->imgfilename = $screenshot_name;
$newcookbook->imgthumbname = tn_.$random.'-'. $screenshot_name;
$newcookbook->expic1 = $random.'-'. $pic1_name;
$newcookbook->expic1_tn = tn_ .$random.'-'. $pic1_name;
$newcookbook->expic2 = $random.'-'. $pic2_name;
$newcookbook->expic2_tn = tn_ .$random.'-'. $pic2_name;
$newcookbook->expic3 = $random.'-'. $pic3_name;
$newcookbook->expic3_tn = tn_ .$random.'-'. $pic3_name;
$newcookbook->expic4 = $random.'-'. $pic4_name;
$newcookbook->expic4_tn = tn_ .$random.'-'. $pic4_name;
.
.
.
But here goes wrong.
Code:
case 'save':
$screenshot = (isset($_FILES['screenshot']['tmp_name']) ? $_FILES['screenshot']['tmp_name'] : "");
$screenshot_name = (isset($_FILES['screenshot']['name']) ? $_FILES['screenshot']['name'] : "");
$pic1 = (isset($_FILES['pic1']['tmp_name']) ? $_FILES['pic1']['tmp_name'] : "");
$pic1_name = (isset($_FILES['pic1']['name']) ? $_FILES['pic1']['name'] : "");
$pic2 = (isset($_FILES['pic2']['tmp_name']) ? $_FILES['pic2']['tmp_name'] : "");
$pic2_name = (isset($_FILES['pic2']['name']) ? $_FILES['pic2']['name'] : "");
$pic3 = (isset($_FILES['pic3']['tmp_name']) ? $_FILES['pic3']['tmp_name'] : "");
$pic3_name = (isset($_FILES['pic3']['name']) ? $_FILES['pic3']['name'] : "");
$pic4 = (isset($_FILES['pic4']['tmp_name']) ? $_FILES['pic4']['tmp_name'] : "");
$pic4_name = (isset($_FILES['pic4']['name']) ? $_FILES['pic4']['name'] : "");
$random = randomgenerator(5);
cookbookHeader(0);
if (strlen($screenshot) > 0 and $screenshot != "none") {
if (move_uploaded_file($screenshot, $mosConfig_absolute_path . $ag_pathimages . "/$screenshot_name")) {
resize_image($mosConfig_absolute_path . $ag_pathimages . "/$screenshot_name", $mosConfig_absolute_path . $ag_pathimages . "/$random-$screenshot_name", "$ag_picturewidth", "$ag_thumbcreation", "$ag_picturequality");
resize_image($mosConfig_absolute_path . $ag_pathimages . "/$screenshot_name", $mosConfig_absolute_path . $ag_paththumbs . "/tn_$random-$screenshot_name", "$ag_thumbwidth", "$ag_thumbcreation", "$ag_thumbquality");
}
}
If I add $random = randomgenerator(5); in the case 'save'
Then, another radom is generated. So the name in the database is not the same as the name of the file on the server.
And if I am not using $random = randomgenerator(5); in the case 'save'. It is not generated a random and my picture will be copied to the server, without random. The same problem, the name in the database is not the same as the name of the file on the server. In the database with radom and on the server without randon.
How can I fix this?
Thx