Jump to content

Search the Community

Showing results for tags 'files'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 17 results

  1. I've got a dev server which, for reasons I won't go into, needs to have different .htaccess files for each site (and subfolders within them) within it. But not always. What I need to do is: - For the folder I put the PHP script in, and every folder under it (the whole tree under it): - If there's a .htaccess file an no .htaccess.dev file, copy .htaccess and name the copy .htaccess.dev (and look in subfolders) If there's a .htaccess file and also a .htaccess.dev file, do nothing (but keep looking for subfolders) If there's neither a .htaccess or .htaccess.dev file, do nothing (but keep looking for subfolders) I'd try to come up with something myself, but getting it wrong will be fairly catastrophic! I'm sure the conditional copy / rename bit is relatively straightforward, but it's the recursive searching of the whole file-system under the script's location that I'm not sure about... Any help greatly appreciated, as always! I have SSH access, if it's easier done that way maybe I'm approaching it wrong?
  2. Hi people, Now before you say that it is a bad idea. I want to figure out a something before I ever trying to do such a thing for something serious. I was arguing with my colleague about the matter. He's quite an old guy with a lot of php/MySQL experience. So he is on the side of storing the files and especially pictures in MySQL database. I myself just store the reference to the file saving on database size and speed. His main point is that the path to the file can get lost and in the result all you will have is a blank web-page on the output. He gave me a piece of used up code for accomplishing this. Can be found at http://www.techcubetalk.com/2009/01/tutorial-on-how-to-store-images-in-mysql-blob-field/ and come other places. Same thing everywhere. But this thing is as broken as it can be and the output is not an error or any other message but the half of the code on the main page. Something like this 0) { $fileName = $_FILES['imgfile']['name']; // image file name $tmpName = $_FILES['imgfile']['tmp_name']; // name of the temporary stored file name $fileSize = $_FILES['imgfile']['size']; // size of the uploaded file $fileType = $_FILES['imgfile']['type']; // file type $fp = fopen($tmpName, 'r'); // open a file handle of the temporary file $imgContent = addslashes(fread($fp, filesize($tmpName))); // read the temp file // $imgContent = fread($fp, filesize($tmpName)); // read the temp file fclose($fp); // close the file handle $query = "INSERT INTO img_up (`name`, `type`, `size`, `content` ) VALUES (’$fileName’, ‘$fileType’, ‘$fileSize’, ‘$imgContent’)"; mysql_query($query) or die('Error, query failed'); $imgid = mysql_insert_id(); // autoincrement id of the uploaded entry mysql_close($dbconn); echo " Image successfully uploaded to database "; echo "View Image"; }else die("You have not selected any image"); ?> When he showed me one of the databases I've seen all the blobs filled with data. And it works all the time. But he refuses to show how and what he's done. Only a hint that he changed a few parts of that thing. How does he do that?
  3. Hallo everyone... here is my following code. i am fetching the picture from the file but unable to fetch it. kindly help me. error in bold underline... Thanks <!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=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php session_start(); $uid=''; include("connection.php"); $query=mysql_query("SELECT * FROM users WHERE uid='".$_GET['uid']."'"); $row=mysql_fetch_array($query); $image=$row['images_path']; ?> <form action="edit.php" method="post"> <table border="1px" align="center" width="85%"> <tr> <td colspan="3"><?php include'header.php' ?></td> </tr> <input type="hidden" name="uid" value="<?=$_GET['uid'];?>" /> <tr> <td colspan="3">Welcome <?php echo $_GET['uid']; ?> </td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">User Name</td> <td width="63%"> <input type="text" name="uname" value="<?php echo $row['uname']?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">User Email</td> <td width="63%"> <input type="text" name="email" value="<?php echo $row['email'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Mobile</td> <td width="63%"> <input type="text" name="mob" value="<?php echo $row['mob'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Type</td> <td width="63%"> <input type="text" name="type" value="<?php echo $row['type'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Status</td> <td width="63%"> <input type="text"name="status" value="<?php echo $row['status'];?>" /></td> </tr> <tr height="30px;"> <td width="37%" style="padding-left:250PX;">Picture</td> <td><?php echo "<img border=\"0\" src=\"".$row['images_path']."\" width=\"102\" alt=\"your name\" height=\"91\">"; ?></td> </tr> </tr> <tr height="50px;"> <td colspan="3" style="padding-left:350px;"><input type="submit" name="submit" /> <input type="reset" value="Clear" /></td> </tr> <tr> <td colspan="3"><?php include'footer.php' ?></td> </tr> </table> <div align="left"><a href="home_users.php">Home</a></div> </form> </body> </html> ------------------ Thanks in advance
  4. Hi Guys I trying to download files and I have this error message, hopelly you guys can help me please Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 14 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 15 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 16 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 17 Warning: Cannot modify header information - headers already sent by (output started at /home/content/04/12746204/html/Digital/core/inc/init.inc.php:6) in /home/content/04/12746204/html/Digital/download.php on line 18 This is the code I use to force the download <?php include('core/inc/init.inc.php'); if(isset($_GET['file_id'])) { $file_id=(int)$_GET['file_id']; $file=mysql_query("SELECT file_name, file_expiry FROM files WHERE file_id=$file_id"); if(mysql_num_rows($file)!=1){ echo'Invalid file Id'; }else{ $row=mysql_fetch_assoc($file); if ($row['file_expiry']<time()){ echo'This file has expired'; }else{ $path="core/files/{$row['$file_name']}"; header('Content-Type:application/octet-stream'); header('Content-Description:File Transfer'); header('Content-Transfer-Encoding:binary'); header("Content-Disposition:attachment;filename=\"{$row['file_name']}\""); header('Content-Length:'.filesize($path)); readfile($path); } } } ?> Thank you for your help.....
  5. Hello, I'm having a bit of a problem with some code of mine. I need to save an image file however I'm not sure where I have gone wrong. So as a bit of background, in my public_html folder I have the 'Add News' file where the user will fill in a form and upload it to the database and a folder called 'news' where the images will be stored... the script to add the article (along with the image) is stored in a folder called functions. Okay so now for the code: This is the form to add the article: <form id="form" action="functions/newsadd.php" method="post"> <table class="input"> <tr><td>News Title</td><td><textarea name="title" cols="80" rows="1"></textarea></td></tr> <tr><td>Author</td><td><textarea name="author" cols="80" rows="1"></textarea></td></tr> <tr><td>Status</td><td><select name="stat"><option>Enabled</option><option>Disabled</option></select></td></tr> <tr><td>Snippet Text</td><td><textarea name="snip" cols="80" rows="6"></textarea></td></tr> <tr><td>News Story</td><td><textarea name="stry" cols="80" rows="15"></textarea></td></tr> <tr><td>Image</td><td><input type='file' name='file'></td></tr> <tr><td><input type="submit" value="submit"/></td></tr> </table> </form> AND this is the code stored in "functions/newsadd.php" <?php $t = $_POST['title']; $a = $_POST['author']; $st = $_POST['stat']; $sn = $_POST['snip']; $s = $_POST['stry']; $conn = mysqli_connect("blah" "blah "blah" "blah") or die ("Could not connect to database"); if(!is_uploaded_file($_FILES['file']['tmp_name'])) { $query = "INSERT INTO news (newstitle,newsauthor,newsdate,newsstatus,newssnippet,newsarticle) VALUES ('$t','$a',CURDATE(),'$st','$sn','$s')"; } else { if ($_FILES['file']['type'] != "image/gif" && $_FILES['file']['type'] != "image/jpeg" && $_FILES['file']['type'] != "image/jpg" && $_FILES['file']['type'] != "image/x-png" && $_FILES['file']['type'] != "image/png") { $query = "INSERT INTO news (newstitle,newsauthor,newsdate,newsstatus,newssnippet,newsarticle) VALUES ('$t','$a',CURDATE(),'$st','$sn','$s')"; } else { $finame = $_FILES["file"]["name"]; $result = move_uploaded_file($_FILES['file']['tmp_name'], "../news/$finame"); if ($result == 1) { $query = "INSERT INTO news (newstitle,newsauthor,newsdate,newsstatus,newssnippet,newsarticle,newsimage) VALUES ('$t','$a',CURDATE(),'$st','$sn','$s','$finame')"; } else { $query = "INSERT INTO news (newstitle,newsauthor,newsdate,newsstatus,newssnippet,newsarticle) VALUES ('$t','$a',CURDATE(),'$st','$sn','$s')"; } } } $result = mysqli_query($conn, $query); if($result){ echo "Entered data successfully"; echo "<BR />"; echo "click <a href='sitepath.php'>here</a> to return to News"; } else { echo "Oh No! Something has gone wrong and your article could not be uploaded"; echo "<BR />"; echo "click <a href='http://sitepath.php'>here</a> to return to News"; } mysqli_close($conn); ?> Now I am perfectly able to upload the information in the form into the database, that is fine. My problem is that I am unable to save an image to the server and I'm not sure where I have gone wrong. I know it has something to do with this part of the code: $finame = $_FILES["file"]["name"]; $result = move_uploaded_file($_FILES['file']['tmp_name'], "../news/$finame"); if ($result == 1) { $query = "INSERT INTO news (newstitle,newsauthor,newsdate,newsstatus,newssnippet,newsarticle,newsimage) VALUES ('$t','$a',CURDATE(),'$st','$sn','$s','$finame')"; } I am just unsure on what it is..... Any help would be appreciated, thanks
  6. Hi, I want to create a place to receive large files from my customers. This is how it supposed to look like: http://sextantecontratos.com.br/restrito.php It should be able to let user upload files <30MB and with specifc extensions shown. However, I'm not able to make it fully working. I did get file upload succesfully thru coding below, which means my server is ok. <html> <body> <form enctype="multipart/form-data" action="teste.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="32000000"> Send this file: <input name="userfile" type="file"> <input type="submit" value="Send File"> </form></body></html> and <?php $uploaddir = './'; $uploadfile = $uploaddir . $_FILES['userfile']['name']; print "<pre>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {print "TESTE OK (arquivo valido e carregado com sucesso). Dados:\n"; print_r($_FILES);} else {print "ERRO NA OPERAÇÃO. Dados:\n"; print_r($_FILES);} print "</pre>"; ?> But when I face the "restrito.php" code, I can't make it work... Can anyone please help?
  7. @move_uploaded_file( $upload_Temp , $uploadFile); chmod($uploadFile, 0644); $upload_URL = "uploads/".$upload_Name ; $uploadFile = "uploads/".$upload_Name ; $id=$_POST['id']; $name=$_POST['name']; $upload_Name=($_FILES['FILE']['name']); //Writes the information to the database mysql_connect("localhost", "freak_admin", "what") or die(mysql_error()); mysql_select_db("freak_doc") or die(mysql_error()); mysql_query("INSERT INTO `users_cv` VALUES ('$id', '$name', '$upload_Name')"); Hello Good Php Gurus! i have tried to find my way around this but no show.from the php admin everything works fine including the name of the file visible. the above code works when i view the info on my view.php(the field for name shows) however the field for upload_name is blank because the idea I had isnt working below <td> echo "<a href=" ./ $upload_URL . basename($row_users['file']) . "> {$row_users['upload_Name']}</a>";</td> Can someone help me with what i am doing wrong? thanks newbie
  8. Hi guys, Getting fruastrated on the following problem. I was wondering how do I make it so that when the user logs in, it will go through my user.dat file and if the username and password matches, it will let them log in. If not then, re enter the information. I know that it's not secure doing it this way, but it's for a simple project. I have the following so far: login.php <?php include "functions.inc"; //if the form data is clicked... if all valid.. display invoice... otherwise display error $datafile = "users.dat"; $file = file_get_contents($datafile); if(!strpos($file, "search string")) { echo ""; } if (array_key_exists('submit', $_POST)) { if(!strpos($file, "search string")) { echo ""; } header('Location: registration.php'); } else if (array_key_exists('register', $_POST)) { header('Location: invoice.php'); } ?>
  9. simple question what is the meaning and purpose of this: if($_FILES) thanks, cheers!
  10. I am importing a text/csv file and instead of importing all of the 'columns' (there are 15 columns on each line), I would like to import column number 1, 4, 15. I have the following code that will import the whole file into an array which works fine but i don't want the whole file in the array becuase I also need to do something like array_unique() where i filter out any duplicates once I have my 3 columns imported into an array. My question is: 1. How do i import the file to only read in the columns i want 2. Once I have all the data into an array , how do i get all the unique rows (so in theory the array size could be halved) Any help greatly appreciated # Open the File. if (($handle = fopen($files, "r")) !== FALSE) { # Set the parent multidimensional array key to 0. $nn = 0; while (($data = fgetcsv($handle, 1000, "|")) !== FALSE) { # Count the total keys in the row. $c = count($data); # Populate the multidimensional array. for ($x=0;$x<$c;$x++) { $csvarray[$nn][$x] = $data[$x]; } $nn++; } # Close the File. fclose($handle); //rename('imports/' . $files, 'archived/' . $files); }
  11. I have these files in a directory and can easily list to a webpage Daily_CD_20130902.xml Daily_CD_20130903.xml Daily_CO_20130902.xml Daily_CO_20130903.xml Daily_CU_20130902.xml Daily_CU_20130903.xml Daily_EQ_20130902.xml Daily_EQ_20130903.xml Daily_IR_20130902.xml Daily_IR_20130903.xml However, i want to be selective and just select the most recent of each type, so instead of the whole list i want to display Daily_CD_20130903.xml Daily_CO_20130903.xml Daily_CU_20130903.xml Daily_EQ_20130903.xml Daily_IR_20130903.xml Is there an easy way to do this or do i need to take apart the filename, put the date in a date object and then use it to sort. my current code is: public function getFiles() { //return String, form as HTML later $return = ""; // create a resrouce pointing to the directory with the files in it on disk $dir = opendir('DIRECTORY'); //path to that directory that is appended to the URL $actualdir = 'PATH FROM WEBSERVER ROOT'; // read the directory looping over the files and populate to an array while ($entryName = readdir($dir)){ $dirArray[] = $entryName; } //close the directory as we don't need it anymore closedir($dir); //make a note of how many items are in the directory $indexCount = count($dirArray); //loop through the files building up a list of links for($index=0; $index < $indexCount; $index++) { if($dirArray[$index] !="." && $dirArray[$index] !=".."){ $return .= "<a href='"."$actualdir".$dirArray[$index]."'>".$dirArray[$index]."</a><br/>"; } } return $return; } any help is appreciated as this is my first day of PHP
  12. Hi everyone. I create a website and now i want to optimize it and well structure it. Actually, all php file are in root directory and i want to well structure it. Is there a better way to structure it? i mean, include file should be with or not with display php page?, And what about processing page that validate form and inserting/update row in database then redirect to another page... they should be in their own folder? Thanks for your help. Pascal
  13. Ok I have some code that's really starting to bug me... The form right under posts to a page and php picks it up and processes it. My problem is that the php will pick up the data and process it if the fields are not filled in or if only one but not both file input are selected. I want to be able to upload both at the same time.The other $POST variable post just fine but not when both $FILES are selected. P.s. I cleaned up the code a bit so its easier to read its not exactly how it is on my site please help! <form action="/administration/xxupload/" method="post" enctype="multipart/form-data"> <input type="hidden" name="artist_id" value="<?php echo $id; ?>" /> </span><input type="text" name="title" id="title" /> <span>Artwork:</span><input type="file" name="art" id="artwork"/> <span>Song:</span><input type="file" name="content" id="content"/> ><span>Details:</span><br/><textarea id="detail" name="detail" ></textarea> <input type="hidden" name="type" value="1" /> <input type="hidden" name="user" value="Admin" /> <input type="hidden" name="time" value="<?php echo time() ?>" /> <div id="tagsdiv">Tags:<input type="text" name="tags" /></div> <div id="submit"><input type="submit" name="upload_single"/></div> </form> Part of xxupload.php if (isset($_POST['upload_single'])){ $artist_id=$_POST['artist_id']; $artist_display=mysql_fetch_assoc(mysql_query("SELECT name FROM artists WHERE id=".$artist_id)); $artist_name=$artist_display['name']; $title=$_POST['title']; $tmp_art_name=$_FILES['art']['tmp_name']; $old_art_name=$_FILES['art']['name']; $dest_art="../media/singles/artwork/".$old_art_name; move_uploaded_file($tmp_art_name,$dest_art); $realart="../media/singles/artwork/".$artist_name."-".$title.".jpg"; $art="/media/singles/artwork/".$artist_name."-".$title.".jpg"; rename($dest_art,$realart); $tmp_content_name=$_FILES['content']['tmp_name']; $old_content_name=$_FILES['content']['name']; $dest_content="../media/singles/".$old_content_name; move_uploaded_file($tmp_content_name,$dest_content); $realcontent="../media/singles/".$artist_name."-".$title.".mp3"; $content="/media/singles/".$artist_name."-".$title.".mp3"; rename($dest_content,$realcontent); $detail=$_POST['detail']; $tags=$_POST['tags']; $type=$_POST['type']; $user=$_POST['user']; $tic=$_POST['time']; mysql_query ("INSERT INTO media(artist_id,title, art, content, detail,tags,user,type,tic) VALUES ('$artist_id','$title','$art','$content','$detail','$tags','$user','$type','$tic')"); header( 'Location: /administration/' ) ; } elseif
  14. Hi, I was wondering but how would I make it so that people when on my site can't access certain files like 'footer.php' which is used as an include in PHP like so: include 'footer.php'; Basically I just want it so if the person tries to access domain.com/footer.php it'll return an error. Thanks.
  15. Hey, I have written some code below to see if a file exists before uploading the file into the server, and if it does exists then assign the message to the variable $message and the echo it out if $message is not empty. However it doesn't seem to work. I'm not sure what I am doing incorrectly here. The code is under line 19 and 20. $upload_errors = array( UPLOAD_ERR_OK => "No Errors.", UPLOAD_ERR_INI_SIZE => "Large than upload_max_filesize", UPLOAD_ERR_FORM_SIZE => "Larger than from MAX_FILE_SIZE", UPLOAD_ERR_PARTIAL => "Partial Upload", UPLOAD_ERR_NO_FILE => "No File", UPLOAD_ERR_CANT_WRITE => "Can't write to the disk", UPLOAD_ERR_EXTENSION => "File upload stopped by extension"); if(isset($_POST['submit'])) { $tmp_file = $_FILES['file_upload']['tmp_name']; $target_file = basename($_FILES['file_upload']['name']); $upload_dir = "uploads"; $new = file_exists(basename($_FILES['file_upload']['name'])) ? false:true; // Set this to false if the file already exists if($new)// test to see if the file is a new file, and if it is then do the following otherwise diplay message { if(move_uploaded_file($tmp_file, $upload_dir."/".$target_file)) { $message = "File uploaded successfully."; } else { $error = $_FILES['file_upload']['error']; $message = $upload_errors[$error]; } } } else { $message = "File could not be written because it already exists"; } ?> <!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" /> <title>Untitled Document</title> </head> <body> <?php if(!empty($message)) { echo "<p>{$message}</p>"; } ?> <form action="uploads.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input type="file" name="file_upload" /> <input type="submit" name="submit" value="upload" /> </form> </body> </html>
  16. I am trying to store images in a folder on server. For some reason the images that need to be uploaded should be with their orignal name as uploaded by user i.e they can be changed only wth the original name in it. 1)So how can i put it in folder using php and retrieve it wherever needed whch means the name should be in database. 2)Now in the folder if two files with the same name are uploaded then the latest would overwrite whch should be avoided. Plz could anyone give some way to make ths up.
  17. Hello. I'm having trouble understanding the below code: <?php $dirName = 'secondDir'; $handle = opendir($dirName); while($printFiles = readdir($handle)){ if($printFiles != '.' && $printFiles != '..'){ echo "<a href = '".$dirName.'/'.$printFiles."'>".$printFiles."</a></br>"; } } closedir($handle); ?> Specifically, it's the if statement that's giving me a hard time. I know what it is, and I know what it does, but I don't understand the logic behind the condition; how does it work to remove the dots before the file list? Are the dots part of the readdir structure? If they are, then how come they can be removed by asking to print out a file list IF they aren't a part of it? I'm not sure if I am making any sense, but if anybody understands, could you please explain this to me? Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.