Search the Community
Showing results for tags 'filename'.
-
Hello, I have csv filename with date. Everyday i have same csv file with respective date. I need to read filename (everyday date changes in filename) and do operation. For example, I have file "cells_20140106_165532.csv". I did like this to read it in general: $filename = "cells_".date('Ymd_hmi').".csv"; $file_contents = file_get_contents($filename); $importcsvsql = ""; It is taking current date instead of filename's date. It is generating empty file "cells_20140114_110109.csv" Thanks in advanced.
-
I am new to php and I've downloaded a free source code for image gallery. It has admin account and you can upload image on it. Now when I upload image it generates random image title like numbers '4849404'. I want it to assign a specific title per image or just simply fetch the file name of the uploaded image and assign it as the title. How can I do that? here is the code.... $RandomNumber = rand(0, 9999999999); // We need same random name for both files. // some information about image we need later. $ImageName = strtolower($_FILES['ImageFile']['name']); $ImageSize = $_FILES['ImageFile']['size']; $TempSrc = $_FILES['ImageFile']['tmp_name']; $ImageType = $_FILES['ImageFile']['type']; $process = true; //Validate file + create image from uploaded file. switch(strtolower($ImageType)) { case 'image/png': $CreatedImage = imagecreatefrompng($_FILES['ImageFile']['tmp_name']); break; case 'image/gif': $CreatedImage = imagecreatefromgif($_FILES['ImageFile']['tmp_name']); break; case 'image/jpeg': $CreatedImage = imagecreatefromjpeg($_FILES['ImageFile']['tmp_name']); break; default: die('Unsupported File!'); //output error } //get Image Size list($CurWidth,$CurHeight)=getimagesize($TempSrc); //get file extension, this will be added after random name $ImageExt = substr($ImageName, strrpos($ImageName, '.')); $ImageExt = str_replace('.','',$ImageExt); $BigImageMaxWidth = $CurWidth; $BigImageMaxHeight = $CurHeight; //Set the Destination Image path with Random Name $thumb_DestRandImageName = $Thumb.$RandomNumber.'.'.$ImageExt; //Thumb name $DestRandImageName = $DestinationDirectory.$RandomNumber.'.'.$ImageExt; //Name for Big Image //Resize image to our Specified Size by calling our resizeImage function. if(resizeImage($CurWidth,$CurHeight,$BigImageMaxWidth,$BigImageMaxHeight,$DestRandImageName,$CreatedImage)) { //Create Thumbnail for the Image resizeImage($CurWidth,$CurHeight,$ThumbMaxWidth,$ThumbMaxHeight,$thumb_DestRandImageName,$CreatedImage); //respond with our images echo '<table width="100%" border="0" cellpadding="4" cellspacing="0"> <tr><td align="center"><img src="gallery/'.$RandomNumber.'.'.$ImageExt.'" alt="Resized Image"></td></tr></table>'; }else{ die('Resize Error'); //output error }
-
Hi everybody ! I have a big problem with my images on my FTP... A friend has uploaded thousands of images with a "+" character in the filename on our FTP. For some reasons, my CMS doesn't support it and I need to change the "+" character by a "_" character, directly on the FTP cause it will rake too much time to download all the images and upload them again. So I need a script (PHP ?) that will go in the right subdirectory and replace the "+" if it exists by the "_" character. Someone could help me ? Thanks, Cedric