machta Posted June 5, 2014 Share Posted June 5, 2014 Hello I am new here, and so i am to php.. i have a small question - i think anyone here could help me, im sure :-) I have a php-gallery running locally on my desktop (using xampp), the gallery just shows images from a directory where a webcam saves its pictures in it (the gallery is named "ubergallery" - maybe anyone knows this gallery). Now i really would like to have following option: - A Button on the thumbnail called "delete" - when clicking on it, the picture should get replaced with another, predefined, placeholder-picture. I really hope somebody here can help me ! Thank you so much for your time ! I have attached the files! UberGallery.php index.php index.php Quote Link to comment https://forums.phpfreaks.com/topic/289002-delete-image-from-folder/ Share on other sites More sharing options...
Maq Posted June 5, 2014 Share Posted June 5, 2014 What have you tried (post only relevant code)? Quote Link to comment https://forums.phpfreaks.com/topic/289002-delete-image-from-folder/#findComment-1481992 Share on other sites More sharing options...
machta Posted June 5, 2014 Author Share Posted June 5, 2014 well, i really dont have a lot of knowledge in php.. so i think this is the relevant code in the template: <div id="galleryListWrapper"> <?php if (!empty($galleryArray) && $galleryArray['stats']['total_images'] > 0): ?> <ul id="galleryList" class="clearfix"> <?php foreach ($galleryArray['images'] as $image): ?> <li><a href="/blumenstein/index.php"><img src="<?php echo $image['thumb_path']; ?>"/></a></li> <?php endforeach; ?> </ul> <?php endif; ?> </div> and this should be the function: /** * Returns pre-formatted XHTML of a gallery * * @param string $directory Relative path to images directory * @param string $relText Text to use as the rel value * @return object Self * @access public */ public function createGallery($directory, $relText = 'colorbox') { // Get the gallery data array and set the template path $galleryArray = $this->readImageDirectory($directory); $templatePath = $this->_appDir . '/templates/defaultGallery.php'; // Set the relative text attribute $galleryArray['relText'] = $relText; // Echo the template contents echo $this->readTemplate($templatePath, $galleryArray); return $this; } /** * Returns an array of files and stats of the specified directory * * @param string $directory Relative path to images directory * @return array File listing and statistics for specified directory * @access public */ public function readImageDirectory($directory) { // Set relative image directory $this->setRelativeImageDirectory($directory); // Instantiate gallery array $galleryArray = array(); // Get the cached array $galleryArray = $this->_readIndex($this->_index); // If cached array is false, read the directory if (!$galleryArray) { // Get array of directory $dirArray = $this->_readDirectory($directory); // Loop through array and add additional info foreach ($dirArray as $key => $image) { // Get files relative path $relativePath = $this->_rImgDir . '/' . $key; $galleryArray['images'][htmlentities(pathinfo($image['real_path'], PATHINFO_BASENAME))] = array( 'file_title' => str_replace('_', ' ', pathinfo($image['real_path'], PATHINFO_FILENAME)), 'file_path' => htmlentities($relativePath), 'thumb_path' => $this->_createThumbnail($image['real_path']) ); } // Add statistics to gallery array $galleryArray['stats'] = $this->_readGalleryStats($this->_readDirectory($directory, false)); // Add gallery paginator to the gallery array $galleryArray['paginator'] = $this->_getPaginatorArray($galleryArray['stats']['current_page'], $galleryArray['stats']['total_pages']); // Save the sorted array if ($this->_config['cache_expire'] > 0) { $this->_createIndex($galleryArray, $this->_index); } } // Return the array return $galleryArray; } /** * Returns a template string with custom data injected into it * * @param string $templatePath Path to template file * @param array $data Array of data to be injected into the template * @return string Processed template string * @access private */ public function readTemplate($templatePath, $data) { // Extract array to variables extract($data); // Start the output buffer ob_start(); // Include the template include $templatePath; // Set buffer output to a variable $output = ob_get_clean(); // Return the output return $output; } i hope this will help you - thank you for your time ! Quote Link to comment https://forums.phpfreaks.com/topic/289002-delete-image-from-folder/#findComment-1481996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.