Gary´s Cookbook Homepage - problem with name of photo's - Gary´s Cookbook Forum
Da die Version von Garys Cookbook für Joomla 1.0x nicht mehr gepflegt wird werden in diesm Forum nur noch allgemeine Fragen beantwortet.

problem with name of photo's

  • xortje
  • Topic Author
  • New Member
  • New Member
More
18 years 8 months ago #1868 by xortje
problem with name of photo's was created by xortje
I have a problem with photos.

If I have recipe 1 with a picture with name foto_1.jpg

Then if i send a second recipe with a photo with name foto_1.jpg (the same name as a Existing photo). Then, the first photo replaced with the second, that's not the intention.

Is it possible for all the names of photo's automatically replace such thing as naam_jhkfhs7397534.jpg or naam_jhihiu68768.gif?


Sorry for my bad English.

thank you for your helping.

Please Log in to join the conversation.

  • Gerald
  • Offline
  • Administrator
  • Administrator
  • Think Pink
More
18 years 8 months ago #1871 by Gerald
Replied by Gerald on topic Aw: problem with name of photo's
At the Version vor Joomla1.5 in neer time the Problem was fixed.

Moderator Developer of Gary´s Cookbook

Please Log in to join the conversation.

  • xortje
  • Topic Author
  • New Member
  • New Member
More
18 years 8 months ago #1874 by xortje
Replied by xortje on topic Aw: problem with name of photo's
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

Please Log in to join the conversation.

Time to create page: 0.087 seconds