Posts

Showing posts with the label files

Function Oriented File Upload PHP

Image
Put the Following Function here: <?php function uploadimgfile($index,$folder="other",$prefix="other") { $target_dir  = "upload_directory_path/";  // try to put full physical path  // identity accstatement address advtimg other $uploadOk = 1; $senddata = array(); $senddata['data'] = "NILL"; $notallowed = array("php","js","css","html");  // defined here the extesion not to upload $shownotallowed = "PHP, JS, CSS, HTML fie is not allowed to upload."; $extension = explode(".",basename($_FILES[$index]["name"])); $extension = end($extension); ECHO "<hr/>" . $realfilnename = basename($_FILES[$index]["name"]); $datetofolder = date("Y/M/d"); $datetofolder = strtolower($datetofolder); $checkdirectory = $targ

Replace a specific keyword on all files name in a folder

Image
Suppose, we have to change some keyword within a folder for all files name. For that I have written a small program, Its take a folder name and take all the files's name of the folder in the array, and we replace the specific keyword with the word, we want there.  Follow the program for the code, you just need to change the first three variable of the code. See Live Example here <?php $dir = 'rename4folder';   // folder path within this file, If are nor sure about the location, just use the full Physical URL of the folder $replacekeyword  = 'replace';  // name to be replaced $replacewith  = 'with';  // name with this the name replacerd $files = scandir($dir); if(is_array($files)) { foreach($files as $single) { $newsingle = str_replace($replacekeyword,$ replacewith,$single); if(($single!=".")&&($single!=" .."))