PHP - Placement Of Web Files
Hello --
Other than organizational clarity for the developer, is there a particular advantage (e.g., security, file access speed, etc.) for placing web files (php, css, html, etc.) in various folders and sub-folders vs placing all files in the root directory or in one particular folder? Thanks. Similar TutorialsHello I have a simple question about file handling... Is it possible to list all files in directories / subdirectories, and then read ALL files in those dirs, and put the content of their file into an array? Like this: array: [SomePath/test.php] = "All In this php file is being read by a new smart function!"; [SomePath/Weird/hello.txt = "Hello world. This is me and im just trying to get some help!";and so on, until no further files exists in that rootdir. All my attempts went totally crazy and none of them works... therefore i need to ask you for help. Do you have any ideas how to do this? If so, how can I be able to do it? Thanks in Advance, pros So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir = "upload/"; $fileName = basename($_FILES["file"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $Thumbnail = "upload/Thumbnails/'$fileName'"; if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){ // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif','pdf', "webm", "mp4"); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; $targetFilePathArg = escapeshellarg($targetFilePath); $output=null; $retval=null; //exec("convert $targetFilePathArg -resize 300x200 ./upload/Thumbnails/'$fileName'", $output, $retval); exec("convert $targetFilePathArg -resize 200x200 $Thumbnail", $output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; echo "Thumbnail equals $Thumbnail\n" ; } }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, mp4, webm & PDF files are allowed to upload.'; } }else{ $statusMsg = 'Please select a file to upload.'; } //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg ; } else { echo "\n Failed to update Thumbnail. Thumbnail equals $Thumbnail" ; } // Display status message echo $statusMsg; ?> And this does work on most files however it is not working on a 9.9mb png fileĀ which is named "test.png" I tested on another 3.3 mb gif file and that failed too? For some reason it returns the following Updated the thumbnail to sql correctly.Updated the thumbnail to sql correctly. Whereas on the files it works on it returns REturned with status 0 and output: Retval is null Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif' Failed to update Thumbnail. Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif'The file rainbow-trh-stache.gif has been uploaded successfully. Any idea on why this is? I am using WPSQT plugin in my blog site .I code some files in PHP also.how to add that files in plugin files.
Hello, I have this script that I am trying to work with, it works and It is a basic image viewer/Gallery and it reads from a directory, I have all my images like so 1.png, 2.png, 3.png etc. They show up just wonderful and does what I want it to do. but I cannot get it to read the directory in numeric form. Here is my code that I am working with <?php require_once("data/connect.php"); // set the absolute path to the directory containing the images define ('IMGDIR', 'birthday/'); // same but for www define ('WEBIMGDIR', 'birthday/'); // set session name for slideshow "cookie" define ('SS_SESSNAMEB', 'slideshow_sessb'); // global error variable $err = ''; // start img session session_name(SS_SESSNAMEB); session_start(); // init slideshow class $ss = new slideshow($err); if (($err = $ss->init()) != '') { header('HTTP/1.1 500 Internal Server Error'); echo $err; exit(); } // get image files from directory $ss->get_images(); // set variables, done. list($curr, $caption, $first, $prev, $next, $last) = $ss->run(); /* slideshow class, can be used stand-alone */ class slideshow { private $files_arr = NULL; private $err = NULL; public function __construct(&$err) { $this->files_arr = array(); $this->err = $err; } public function init() { // run actions only if img array session var is empty // check if image directory exists if (!$this->dir_exists()) { return 'Error retrieving images, missing directory'; } return ''; } public function get_images() { // run actions only if img array session var is empty if (isset($_SESSION['imgarr'])) { $this->files_arr = $_SESSION['imgarr']; } else { if ($dh = opendir(IMGDIR)) { while (false !== ($file = readdir($dh))) { if (preg_match('/^.*\.(jpg|jpeg|gif|png)$/i', $file)) { $this->files_arr[] = $file; } } closedir($dh); } $_SESSION['imgarr'] = $this->files_arr; } } public function run() { $curr = 1; $last = count($this->files_arr); if (isset($_GET['img'])) { if (preg_match('/^[0-9]+$/', $_GET['img'])) $curr = (int) $_GET['img']; if ($curr <= 0 || $curr > $last) $curr = 1; } if ($curr <= 1) { $prev = $curr; $next = $curr + 1; } else if ($curr >= $last) { $prev = $last - 1; $next = $last; } else { $prev = $curr - 1; $next = $curr + 1; } // line below sets the caption name... $caption = str_replace('-', ' ', $this->files_arr[$curr - 1]); $caption = str_replace('_', ' ', $caption); $caption = preg_replace('/\.(jpe?g|gif|png)$/i', '', $caption); $caption = ucfirst($caption); return array($this->files_arr[$curr - 1], $caption, 1, $prev, $next, $last); } private function dir_exists() { return file_exists(IMGDIR); } } ?> <? // Image files array $image_files = array( ); // Array to store the images that were sorted $image_sorted = array( ); // Read the extension of the file name passed function readExtension( $file ) { $extension = substr( $file, strrpos( $file, '.' ) + 1 ); return $extension; } // This may already exist but I was in a coding frenzy. Obviously, this checks if it is an image or not function isImage( $file ) { $extension = readExtension( $file ); $valid_images = array( "gif", "jpg", "jpeg", "png", "gif" ); for( $i = 0; $i < sizeof( $valid_images ); $i++ ) { if( $extension == $valid_images[ $i ] ) { return true; } } } // Traverse the directory and get all the images in that folder function getImagesInFolder( $dir ) { if( $handle = opendir( $dir ) ) { while( false !== ( $file = readdir( $handle ) ) ) { if( $file != "." && $file != ".." && $file != "Thumbs.db" ) { if( !( is_dir( $dir . $file ) ) ) { $file_fp = $dir . $file; if( isImage( $file_fp ) ) array_push( $GLOBALS['image_files'], $file_fp ); } } } closedir( $handle ); } } //The brunt of the post. Explained below in more detail function sortByModDate( $array_in, &$array_out ) { for( $i = 0; $i < sizeof( $array_in ); $i++ ) { $time_stamp = date("G:i:s-d-m-y", filemtime( $array_in[ $i ] ) ); $array_out[ $array_in[ $i ] ] = $time_stamp; } arsort( $array_out, SORT_STRING ); $array_out = array_keys( $array_out ); if( $array_out[ 0 ] == "0" ) array_shift( $array_out ); unset( $array_in ); } // Get the sorted file by index number. This seems a bit redundant so you can modify as you see fit. function getSortedImageByIdx( $index_num ) { sortByModDate( $GLOBALS['image_files'], $GLOBALS['image_sorted'] ); return $GLOBALS[ '{image_sorted[ $index_num ]}' ]; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>A Great Escape Spalon</title> <!-- BEGIN CSS STYLES --> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> <style type="text/css"> body{margin: 0;padding: 0;font: 100% Verdana, Arial, Helvetica, sans-serif;font-size: 14px;} div#gallery{margin: 40px auto;text-align: center;} div#gallery img{margin: 20px;} div#gallery p{color: #004694;} div#gallery div.pn{padding: 10px;margin: 0 5px;} a{color:#333;} a:hover{color:#cc0000;} a.sp{padding-right: 40px;} </style> <style type="text/css"> #main { position: relative; width: 1024px; margin: 0 auto; height:auto; vertical-align: middle; } #footer {position: absolute; bottom: 0; left: 0; width: 600px; height: 50px;} html, body { background-image:url(img/background.png); background-repeat:repeat-x; } #apDiv1 { position:absolute; background-image:url(img/sides.png); top: 1px; left: 1px; width: 1017px; } #apDiv2 { position:absolute; width:206px; height:384px; z-index:3; left: 50px; top: 127px; } #apDiv3 { position:absolute; width:216px; height:386px; z-index:4; left: 715px; top: 128px; } #apDiv4 { position:absolute; width:970px; height:115px; z-index:5; top: -1px; left: 1px; } #apDiv5 { position:absolute; width:200px; height:115px; z-index:5; left: 296px; top: 9px; } #apDiv6 { position:absolute; width:342px; height:115px; z-index:2; left: 101px; top: 129px; } #apDiv7 { position:absolute; width:452px; height:115px; z-index:6; left: 295px; top: 177px; } /* Left Menu */ #apDiv8 { position:absolute; width:0px; height:0px; z-index:7; left: 123px; top: 179px; } #apDiv9 { position:absolute; width:3px; height:2px; z-index:8; left: 123px; top: 233px; } #apDiv10 { position:absolute; width:13px; height:2px; z-index:10; left: 123px; top: 272px; } #apDiv11 { position:absolute; width:3px; height:0px; z-index:11; left: 123px; top: 313px; } #apDiv12 { position:absolute; width:1px; height:1px; z-index:12; left: 120px; top: 354px; } #apDiv13 { position:absolute; width:0px; height:0px; z-index:13; left: 120px; top: 399px; } #apDiv14 { position:absolute; width:3px; height:2px; z-index:14; left: 123px; top: 449px; } #apDiv15 { position:absolute; width:1px; height:0px; z-index:15; left: 123px; top: 492px; } #apDiv16 { position:absolute; width:1px; height:1px; z-index:16; left: 123px; top: 537px; } #apDiv17 { position:absolute; width:2px; height:2px; z-index:17; left: 123px; top: 581px; } /* Right Menu */ #apDiv18 { position:absolute; width:2px; height:4px; z-index:18; left: 774px; top: 179px; } #apDiv19 { position:absolute; width:4px; height:0px; z-index:19; left: 774px; top: 233px; } #apDiv20 { position:absolute; width:4px; height:3px; z-index:20; left: 774px; top: 315px; } #apDiv21 { position:absolute; width:49px; height:1px; z-index:21; left: 774px; top: 360px; } #apDiv22 { position:absolute; width:1px; height:1px; z-index:22; left: 774px; top: 405px; } #apDiv23 { position:absolute; width:21px; height:0px; z-index:23; left: 774px; top: 450px; } #apDiv24 { position:absolute; width:3px; height:0px; z-index:24; left: 774px; top: 496px; } #apDiv25 { position:absolute; width:5px; height:0px; z-index:25; left: 774px; top: 536px; } #apDiv26 { position:absolute; width:5px; height:0px; z-index:26; left: 774px; top: 272px; } #apDiv27 { position:absolute; width:0px; height:0px; z-index:27; left: 773px; top: 579px; } #apDiv28 { position:absolute; width:448px; height:501px; z-index:28; left: 277px; top: 137px; } #apDiv29 { position:absolute; width:200px; height:115px; z-index:1; left: 711px; top: 914px; } </style> <!-- END CSS STYLES --> <!-- BEGIN LIGHTBOX JS --> <script type="text/javascript" src="js/prototype.js"></script> <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="js/lightbox.js"></script> <!-- END LIGHTBOX JS --> </head> <body> <!-- MAIN LAYOUT --> <div id=main> <div id="apDiv1"><img src="img/sides.png" width="995" height="1016"/></div> <div id="apDiv2"><img src="img/left_menu/leftmenu.png" /></div> <div id="apDiv3"><img src="img/left_menu/leftmenu.png" /></div> <div id="apDiv4"><img src="img/flower_top.png" width="1016" /></div> <div id="apDiv5"><img src="img/top_logo.png" width="446" /></div> <div id="apDiv6"><img src="img/middle_white_flower.png" width="840" /></div> <div id="apDiv7"><img src="img/back_center.png" width="453"/></div> <!-- END MAIN LAYOUT --> <!-- LEFT MENU BEGIN --> <div id="apDiv8"><img src="img/left_menu/menu.png" /></div> <div id="apDiv9"><a href="page.php?page=introduction"><img src="img/left_menu/introduction.png" border="0" /></a></div> <div id="apDiv10"><a href="page.php?page=hair_services"><img src="img/left_menu/hair_services.png" border="0" /></a></div> <div id="apDiv11"><a href="page.php?page=nail_services"><img src="img/left_menu/nail_services.png" border="0" /></a></div> <div id="apDiv12"><a href="page.php?page=body_treatments"><img src="img/left_menu/body_treatments.png" border="0"></a></div> <div id="apDiv13"><a href="page.php?page=specialties"><img src="img/left_menu/specialties.png" border="0" /></a></div> <div id="apDiv14"><a href="page.php?page=massage"><img src="img/left_menu/massage.png" border="0" /></a></div> <div id="apDiv15"><a href="page.php?page=packages"><img src="img/left_menu/packages.png" border="0" /></a></div> <div id="apDiv16"><a href="page.php?page=facials"><img src="img/left_menu/facials.png" border="0" /></a></div> <div id="apDiv17"><a href="page.php?page=extras"><img src="img/left_menu/extras.png" border="0" /></a></div> <!-- END OF LINKS --> <!-- RIGHT MENU BEGINS --> <div id="apDiv18"><img src="img/right_menu/info.png" /></div> <div id="apDiv19"><a href="page.php?page=price_list"><img src="img/right_menu/price_lists.png" border="0" /></a></div> <div id="apDiv20"><a href="page.php?page=gift_certificate"><img src="img/right_menu/gift_cert.png" border="0" /></a></div> <div id="apDiv21"><a href="page.php?page=meet_the_team"><img src="img/right_menu/meet_the_team.png" border="0" /></a></div> <div id="apDiv22"><a href="page.php?page=news_reviews"><img src="img/right_menu/news_reviews.png" border="0" /></a></div> <div id="apDiv23"><a href="page.php?page=employment"><img src="img/right_menu/employment.png" border="0" /></a></div> <div id="apDiv24"><a href="page.php?page=galleries"><img src="img/right_menu/galleries.png" border="0" /></a></div> <div id="apDiv25"><a href="page.php?page=products"><img src="img/right_menu/products.png" border="0" /></a></div> <div id="apDiv26"><a href="page.php?page=spa_price_list"><img src="img/right_menu/spa_price_lists.png" border="0" /></a></div> <div id="apDiv27"><a href="page.php?page=contact"><img src="img/right_menu/phone_number.png" border="0" /></a></div> <!-- BEGIN CENTER TEXT --> <div id="apDiv28"> <div id="gallery"> <?PHP $title = IMGDIR; $title = str_replace("/"," ",$title); echo $title; ?> <a href="<?=WEBIMGDIR;?><?=$curr;?>" rel="lightbox"><?PHP echo getSortedImageByIdx( 0 ); ?><img src="<?=WEBIMGDIR;?><?=$curr;?>" alt="" width="448" height="350"/></a> <p>Click on the Image to get a better view! or Click <a href="<?=WEBIMGDIR;?><?=$curr;?>" rel="lightbox">Here!</a></p> <div class="pn"> <a href="?img=<?=$first;?>">First</a> | <a href="?img=<?=$prev;?>" class="sp">Previous</a><a href="?img=<?=$next;?>">Next</a> | <a href="?img=<?=$last;?>">Last</a> </div> </div> <!-- END CENTER TEXT --> </div> </div> </body> </html> What I am looking for in help is to be able to get it to show the images in order Here it is working http://agreatescape.org/birthday.php? if you click the image lightbox will pop up but if you look at the image url it will go from 1.png to 58.png etc.. I have looked and looked and tried for hours and cant seem to get my head around it.. Thank you in advance I have a very simple piece of code to create a grid based gallery. The thumbnails are loaded from a single directory and are name 1.jpg... 2.jpg... 3.jpg etc At the moment the images appear to be loaded in randomly. I want them to load in numerically in terms of their filename. I know I may need to use 'sort' or 'natsort' but where in the code? Thanks for any help you can give me Code: [Select] <? $images = "Images/Bag Thumbs/"; # Location of small versions $big = "ruxxwomens.php?id="; # Location of big versions (assumed to be a subdir of above) $cols = 4; # Number of columns to display if ($handle = opendir($images)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != rtrim($big,"/")) { $files[] = $file; } } closedir($handle); } $colCtr = 0; echo '<table width="800" cellspacing="0" cellpadding="0" border="0"><tr>'; foreach($files as $file) { if($colCtr %$cols == 0) echo '</tr><tr>'; echo '<td align="center"><a href="' . $big . $file . '"><img src="' . $images . $file . '" cellspacing="0" cellpadding="0" border="0"></a></td>'; $colCtr++; } echo '</table>' . "\r\n"; ?> first of all...its good to see the site back .
my question guys is i'm wondering is there a way of getting the column number when reading a .cvs file?
ie. a, b, c, d, aa, ab etc?
$row = 1; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); echo "<p> $num fields in line $row: <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { //echo $data[$c] . "<br />\n"; } } fclose($handle); }now $num counts the columns...but i want to convert that into a alphabetical column...is there a easy solution? thanks guys I have told that the php files I was working on contains BOM by default cause of the editor I m using. I have installed other editor that can create php files without BOM. So my question is what's the difference between 2 files, one with BOM and other without BOM ? Any problems I may face for long term usage ? Which one is better to use ? Hey, Trying to learn to generate PDF files, something apparently WAAAAYYY more complex than I thought. Can someone please give me an explanation on '$optlist' from this function..... PDF_load_image ( resource $pdfdoc , string $imagetype , string $filename , string $optlist ) What is it? PHP.net doesn't have any info at all. Thanks, IceKat. BTW - Any (recent) tutorials or pages would be appreciated. Everything I find is out of date or doesn't work. lets say I own a file, and you own a file, both these files are the exact same file, the only difference is the filename. So lets say we both have The Gimp 2.6 but one is named TG2.6.exe and the other is named the_Gimp-2.6.exe. What would be the best way to count the files that are the same even if they have a different file name? Another example would be: I have a file called me.jpg and someone else has a file me.jpg but they are two completely different pictures. What would I do to tell that? Can you include a file and append info to be grabbed by using GET? For example, can you have an include file like this... Code: [Select] include('file.php?id=1'); And then in the file "file.php" I would use $_GET['id'] to do other things in the code. I tried it and it's not working. I'm getting this error... "Warning: include(file.php?id=1) [function.include]: failed to open stream: No such file or directory in..." Just want to find out if this should be doable before I continue testing why it's not working for me. If it should work, should I be using something other than include maybe? (like require or require_once?) I know how to count the files: <?php $dir = $_SERVER[DOCUMENT_ROOT]."/api/sigs/cache/".$i[id]."/"; $files = scandir($dir); $result = count($files); printf("$result Signatures Generated"); ?> But i'm trying to make it so it only counts the files that were modified recently (That Day). Hi there, I'm a beginner at php and mysql. I know a few basics, but i'm stuck. I'm trying to make something for my wifes company that will be as simple as i can make it. The files i have: login/register script (register.php / regcheck.php) member / profile script and a image upload script. (upload.php: which is now in register.php and process.php) What i want to do is: at register i've added a file upload form, but the reg.php points to regcheck.php and the upload.php points to process.php I want to combine those 2 files: regcheck.php and process.php to one file. Now i've been breakin my head over this for 2 day's and i cant find a solution and i'm not that experienced. what i've done so far is the following, but it does'nt fill my database: databas.sql: CREATE TABLE `klanten` ( `id` int(4) unsigned NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL, `level` int(4) default '1', `filename` varchar(255) not null, `mime_type` varchar(255) not null, `file_size` int not null, `file_data` mediumblob not null, primary key (image_id), index (filename) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; <?php ob_start(); function assertValidUpload($code) { if ($code == UPLOAD_ERR_OK) { return; } switch ($code) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $msg = 'Image is too large'; break; case UPLOAD_ERR_PARTIAL: $msg = 'Image was only partially uploaded'; break; case UPLOAD_ERR_NO_FILE: $msg = 'No image was uploaded'; break; case UPLOAD_ERR_NO_TMP_DIR: $msg = 'Upload folder not found'; break; case UPLOAD_ERR_CANT_WRITE: $msg = 'Unable to write uploaded file'; break; case UPLOAD_ERR_EXTENSION: $msg = 'Upload failed due to extension'; break; default: $msg = 'Unknown error'; } throw new Exception($msg); } $errors = array(); try { if (!array_key_exists('image', $_FILES)) { throw new Exception('Image not found in uploaded data'); } $image = $_FILES['image']; // ensure the file was successfully uploaded assertValidUpload($image['error']); if (!is_uploaded_file($image['tmp_name'])) { throw new Exception('File is not an uploaded file'); } $info = getImageSize($image['tmp_name']); if (!$info) { throw new Exception('File is not an image'); } } catch (Exception $ex) { $errors[] = $ex->getMessage(); } if( isset( $_POST['user'] ) && isset( $_POST['pass'] ) ) { if( strlen( $_POST['user'] ) < 4 ) { echo "Username Must Be More Than 4 Characters."; } elseif( strlen( $_POST['pass'] ) < 4 ) { echo "Passwrod Must Be More Than 4 Characters."; } elseif( $_POST['pass'] == $_POST['user'] ) { echo"Username And Password Can Not Be The Same."; } else { include( 'database.php' ); $username = mysql_real_escape_string( $_POST['user'] ); $password = md5( $_POST['pass'] ); $filename = mysql_real_escape_string($image['name']); $mime_type = mysql_real_escape_string($info['mime']); $file_size = $image['size']; $file_data = mysql_real_escape_string(file_get_contents($image['tmp_name']) $sqlCheckForDuplicate = "SELECT username FROM klanten WHERE username = '". $username ."'"; if (count($errors) == 0) { // no errors, so insert the image if( mysql_num_rows( mysql_query( $sqlCheckForDuplicate ) ) == 0 ) { $sqlRegUser = "INSERT INTO klanten( username, password, filename, mime_type, file_size, file_data ) VALUES( '". $username ."', '". $password ."', '". $filename ."', '". $mime_type ."', '". $file_size ."', '". $file_data ."', )"; if( !mysql_query( $sqlRegUser ) ) { echo "You Could Not Register Because Of An Unexpected Error."; } else { echo "You Are Registered And Can Now Login"; $formUsername = $username; header('Location: view.php?id=' . $id); } } else { echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One."; $formUsername = $username; } } } else { echo "You Could Not Be Registered Because Of Missing Data."; } ob_end_clean(); ?> <html> <head> <title>Error</title> </head> <body> <div> <p> The following errors occurred: </p> <ul> <?php foreach ($errors as $error) { ?> <li> <?php echo htmlSpecialChars($error) ?> </li> <?php } ?> </ul> <p> <a href="upload.php">Try again</a> </p> </div> </body> </html> I guess i've mixed up things pretty badly right? Hi All, I am having trouble with this script that was from a example script online, basically I am getting the last error message everytime I try an up a zip file? Unknown Error: No file uploaded <?php include('dbconnect.php'); session_start(); $user_id = $_SESSION['user_id']; $query = " SELECT * FROM roms WHERE user_id = '$user_id' ORDER BY rom_date DESC LIMIT 1"; $result = mysql_query($query); if (!mysql_query($query)) { die('Error: ' . mysql_error()); } while($row = mysql_fetch_array($result)) { $_SESSION['rom_version'] = $row['rom_version']; } if ((!empty($_FILES["rom"])) && ($_FILES['rom']['error'] == 0)) { $filename = $user_id . $_SESSION['rom_version'] . '.zip'; $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "zip") && ($_FILES["rom"]["type"] == "application/zip") && ($_FILES["rom"]["size"] < 2500000)) { $newname = dirname(__FILE__).'roms/'.$filename; if (!file_exists($newname)) { if ((move_uploaded_file($_FILES['uploaded_file'][ 'tmp_name'],$newname))) { echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["rom"]["name"]." already exists"; } } else { echo "Error: Only .zip images under 250mb are accepted for upload"; } } else { echo "Unknown Error: No file uploaded"; } ?> Hey All, First post so please be gentle! I have a website www.antiquesattic.co.uk and i have been left in the lurch and without it being fully finished. I want to add google analytics code to everypage and i am a bit stuck. I have access to the server (apache 2.2.19) and have been able to add site maps etc but i am not sure where to paste the analytics code. Which folder would i look in and whereabouts do i paste. I would be extremely extremely grateful if someone could do me a quick step by step guide Also, if you would like to have a look at the website and give me some feedback that would be great! One final thing, i can't add content to the homepage just auctions, would it be a easy job to get some one to edit the site so i can add say 1000 words of text at the bottom of the homepage from my admin area? Apologies for the noob questions but my expertise is in sales and marketing not coding. Thanks Chris This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=345120.0 Hi! I would appreciate your help... How can i include files with get and post data in order to avoid sql injections? The including data has utf8 encoding... Any suggestions??? Thanks in advanced!!! First what are the possible $_FILES['file']['type'] s of .zip. I know one is "application/x-zip-compressed" but are there any others (basically I need to check if the uploaded file is a .zip? Second question; how could I extract the contents of .zip to a directory on the server without the use of FTP? Thanks im trying to make a program that changes some files from 0 to 1,but im having some trouble... heres my code, Code: [Select] $id = $_GET["id"]; $file1 = "http://mysite.co.cc/users/".$id."/file1.txt"; $fh = fopen($file1, 'w'); fwrite($fh, "1"); fclose($fh); I followed this tut: http://www.tizag.com/phpT/filewrite.php I cant find anything wrong with the code,but it will not make the file have 1 in it. hey, can some one provide a code to help me copy a folder called contents with files in it to another folder called items cheers i am able to create csv's and can do so with no trouble .. but what i am having difficulty with is being able to auto save the csv and then email it all in one script. anybody every dealt with something like this? |