Jump to content

Search the Community

Showing results for tags 'file'.

  • 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 25 results

  1. i try this code to rename file when upload , the file name is rename in the folder or physical file .But in the database , it display 'array' not the name of file .How to save file name in the database ? $targetDirg= "folder/pda-semakan/gambar/"; if($_FILES['gambar']['size'] == 0 && $_FILES['gambar']['name'] == ""){ $fileNameg = $gambar; }else{ $fileNameg =explode(".",$_FILES['gambar']['name']); $newfilename= $stIC.'.'.end($fileNameg); $moveg =move_uploaded_file($_FILES["gambar"]["tmp_name"], $targetDirg.$newfilename); }
  2. Say I have directory setup like this. core/ includes/ snippets/ template.php js/ index.php Say in the index.php file, I have a file path like this " include 'snippets/template.php'; ". It works. Or say If I am in template.php and I have a file path like this " include '../index.php'; ". It works as well. I am wondering if there is a more global method to this so I don't have to worry about when to use "../" or not. It becomes hectic if there are a lot of includes and/or links.
  3. I have a file in the same location as my PHP file, say test.txt, and in multiple locations it has content like: - href="http://www.domain.com/entry.php/256/1/this-is-the-title" or href="http://www.domain.com/entry.php/123/2/another-title" which I need replaced within the file to: - href="{EntryNumber=256.link}" and href="{EntryNumber=123.link}" Only the first number is needed for the replacement, it will be between 1 and 999. Everything between the 5th / and the 2nd " can be safely ignored and removed. This is not the only content in the line, and sometimes there may be more than one occurrence per line. I've got this so far: - $buffer = ""; $fp = file($file); foreach($fp as $line){ $buffer .= preg_replace(***struggling with this bit***); } fclose($fp); echo $buffer; file_put_contents($file, $buffer); Am I along the right lines generally? And I have no idea what the preg_replace should be as my regex is a bit trial and error, more error in this case... As always, any help greatly appreciated! EDIT: If it matters, the largest file I need to edit is 39Kb, and includes 175 occurrences of the replacements.
  4. This is so strange. I have this bit of code that removes the .php extension from pages so that I can visit any page without typing .php at the end. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [L] The above code has always worked for me before. But for some reason today it stopped working on localhost and the live server(ipage hosting). Do you know why that might be?
  5. Hey guys! I have a page that has multiple forms. I am trying to make a button that will save all the information from each textarea to a different .txt file. IE: textarea1 will save to textarea1.txt textarea2 will save to textarea2.txt textarea3 will save to textarea3.txt etc. I am able to save each individual form via individual submit buttons within each form, but I'd like to make a submit button outside of the other forms that saves all forms to their specific files. The code for one of the individual forms looks like this: <form method="post" action="?"> <h1>Physical Stats</h1> <textarea name="stats"><?php include ('resources/stats.txt'); ?></textarea> <br><input type="submit" name="update_stats" value="Update"/> </form> <?php if (isset($_POST['update_stats'])) { file_put_contents("resources/stats.txt", $_POST['stats']); } ?> Everything above works. And the code for the save all form looks like this: <form method="post" action="?"> <input type="submit" name="update_all" value="Update All"/> <br><br> </form> <?php if (isset($_POST['update_all'])) { file_put_contents("resources/stats.txt", $_POST['stats']); file_put_contents("resources/pro_exp.txt", $_POST['pro_exp']); file_put_contents("resources/pro_awards.txt", $_POST['pro_awards']); file_put_contents("resources/ama_exp.txt", $_POST['ama_exp']); file_put_contents("resources/ama_awards.txt", $_POST['ama_awards']); file_put_contents("resources/references.txt", $_POST['references']); } ?> This is the code I currently have and it's just not working. Right now the above code is actually clearing all of the text files. I'm afraid I'm a complete newb to writing scripts and I'm sure there is some rule about file_get_contents that I'm not aware of. Please help! Thanks!
  6. Say I am uploading an image that gets resized. The resized image is a thumb. I have it's file path saved in the database and the image itself saved in a folder. Originally I was saving both to the database and folder. But now that I think about it, do I have to save the orginal image? Wouldn't I be saving up a lot of space if I only save the thumb image? What do you think?
  7. I need to send a cURL request containing a file to upload as well as a JSON string. I can get a properly formatted request when sending the JSON, but the file is throwing it off. $curl_file_object = '@'.$tmp_name $postData= array( 'JSON'=> json_encode($jsonParams), $reference => $curl_file_object, ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $target); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // stop verifying certificate curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: multipart/form-data;")); curl_setopt($curl, CURLOPT_POST, true); // enable posting curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); // post data curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); // if any redirection after upload $response = curl_exec($curl); $info = curl_getinfo($curl); curl_close($curl); debug($info); Am I the first one needing to send file binary data along with a json string to a server at the same time?
  8. I didn't found any nice materials comparing the two ways of information unload to user. Neither have I a firm understanding of how high my learning curve should be in both cases, which of which to choose for better way. I'm a beginner asking for your professional word of advice. Help me to better formulate for search what I want, Please. I know keeping files and images in fs is better served by os/fs-drivers but i'm just learning and just trying to remember select * for "poking around". + i do hate images text analyzing it'll will be! Is it better to save files from MySQL fields via http headers, or it's even more better to perform the saving of the kept txt files (in one specific folder) and all the maintenance of tempfiles on server (archiving, indexing, cron/planning)? So: 1. Learning & get experience in file maintenance? vs 2. Finding out how to deal with protocols (download resuming) What I've found so far: header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length:'); There's a textfield full of appended edits of a specific user (for example list-ordering/or article appending). Headers should deliver it as a file, while skiping the file creation on a server. Or do I just learn how to do it with files and save just file link then accomplish the persistent file-links cleaning (because there would be lots of them)? One one side there is a certain straightforwardness in dealing with files, but then again I'd prefer the both ways while considering continuing to study MySQL-approach. I understand protocols/headers with PHP are no easy task that's why I'm hopefully leaving the last word for the professional.... Thanks in advance!
  9. Hi guys I would like to get whole content of html file after I submitted a password. The problem is that the my code doesn't access the value for the file. I tried to create a session but i doesn't work. What other option do I have to get the content of the html file? session_start(); $selected_file = $_POST['radio1']; // get the filename of the file $fileinfo = pathinfo($selected_file); $filename = $fileinfo['dirname'] . DIRECTORY_SEPARATOR . $fileinfo['filename']; $password = 'code'; $lines = file("$filename.html"); $_SESSION['selectedfile'] = $selected_file; $_SESSION['file'] = $filename; $_SESSION['Scipt'] = ("$filename.html"); $_SESSION['Scipttext'] = $lines; $_SESSION['file2'] = $fileinfo; if (isset($_POST['submitradio'])) { echo '<div class="imageselected">'; echo '<img src="'.$_SESSION['selectedfile'].'" /></br>'.PHP_EOL; echo '</div>'; // check to see if a html file named the same also exists if(file_exists($_SESSION['Scipt'])) { echo "<form action='test_result.php' method='post'>"; echo '<div class="Password">'; echo 'Type in password to view full Script'; echo "<label><div class=\"Input\"><input type='password' name='passIT' value='passit'/></div>"; echo "<input type='submit' name='submitPasswordIT' value='Submit Password'/></div>"; echo '</div>'; echo "$filename.html shares the same name as $selected_file"; for($x = 1;$x<=15;$x++) { header( "Content-Type: file/html" ); $lines = ($_SESSION['Scipttext']); $new = strip_tags($lines); echo $lines[rand(0, count($lines)-1)]."<br>"; } // end of forloop } // end of check // start Sorrytext else { echo '<div class="NoScript">'; echo "Nothing available at the moment."; echo '</div>'; } // end Sorrytext } // End of submitradio if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ echo "You entered correct password"; readfile($_SESSION['Scipt']); } else{ echo "You entered wrong password"; } } echo '</form>'; I would be grateful for help.
  10. I am in the process of creating a script where only certains video types can be uploaded but at the moment am stuck. Here is my code - <?php $title = isset($_POST['title']) ? $_POST['title'] : null; $desc = nl2br(isset($_POST['description'])) ? $_POST['description'] : null; $name = isset($_POST['fullname']) ? $_POST['fullname'] : null; $email = isset($_POST['email']) ? $_POST['email'] : null; $country = isset($_POST['country']) ? $_POST['country'] : null; $video = isset($_FILES['video']); $videoname = isset($_FILES['video']['name']); $videotmp = isset($_FILES['video']['tmp_name']); $videosize = isset($_FILES['video']['size']); $videotype = isset($_FILES['video']['type']); $videoacceptable = array( "video/mp4", "video/ogg", "video/quicktime", ); $videopath = "/videos/"; $videofile = $videopath . $video; if(isset($_POST['submit'])) { //ERROR MESSAGES / VALIDATION if(empty($title)) { $errors[] = "A title is required"; echo "<style type=\"text/css\"> #title { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($title) > 80) { $errors[] = "Your title can only be 80 characters long"; echo "<style type=\"text/css\"> #title { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($desc)) { $errors[] = "A description is required"; echo "<style type=\"text/css\"> #description { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($name)) { $errors[] = "Please enter your full name"; echo "<style type=\"text/css\"> #fullname { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($name) > 32) { $errors[] = "Your name can only be 32 characters long"; echo "<style type=\"text/css\"> #fullname { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if(empty($email)) { $errors[] = "Please enter your email address"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif(strlen($email) > 50) { $errors[] = "Your email addess can only be 50 characters long"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors[] = "Please enter a valid email address"; echo "<style type=\"text/css\"> #email { background-color:#F5A9A9;border:1px solid #DF0101; } </style>"; } if($videosize = 0) { $errors[] = "You forgot to upload a video"; } elseif($videosize >= 20000000) { $errors[] = "Your video size is too large, 20mb max"; } elseif(!in_array($videotype, $videoacceptable)) { $errors[] = "The file type is not allowed, only allowed .mp4, .ogg and .mov"; } if(count($errors) === 0) { $connect = mysqli_connect("localhost","username","password"); if(!$connect) { header("Location:"); // ADD ERROR LINK } $dbselect = mysqli_select_db("database"); if(!$dbselect) { header("Location:"); // ADD ERROR LINK } $query = mysqli_query("INSERT INTO cover_videos(title, desc, name, email, country, videotmp, videotype, videosize, videopath) VALUES('$title','$desc','$name','$email','$country','$videotmp','$videotype','$videosize','$videopath')"); move_uploaded_file($videotmp, $videofile); //SEND AN EMAIL TO THE USER $to = $email; $subject = "Thank's for your upload"; $message = ' <html> <head><title>We have received your video</title></head> <body> <h3>Good News!</h3> <p>We have recieved your video and is awaiting approval.</p> </body> </html> '; $headers = 'FROM: no-replyk' . "\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers = 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); header("Location:"); //SUCCESSFUL UPLOAD PAGE } } ?> So whats happening is when i go to upload a file, im uploading a .mov file but the error message that pops up is "The file type is not allowed, only allowed .mp4, .ogg and .mov" but the .mov mime is in the videoacceptable array so im a bit stuck at the moment, any know whats the problem?
  11. Hi Community! :-) (Sorry for my average english) I recently started coding in php, till now, i allready have advanced skills in programming with C# and thus, had no problems writing my own script. Still, my script does not really work, i'm trying to check if a file contains a md5(string), but the script never finds the string. This is the script: (please don't mind any security issues, this is just a test. But if you have any tips and tricks to improve the security, i'd be glad to receive them) <?php $webname = $_POST["webname"]; $webcode = $_POST["webcode"]; $webpass = $_POST["webpass"]; if (file_exists("web/". $webname . ".html")) { $file = file_get_contents("web/". $webname . ".html", "r"); if (strpos(md5($webpass),$file) !== false) { $usergen = fopen("web/" . $webname . ".html", "w") or die("Unable to open file!"); fwrite($usergen, $webcode); fwrite($usergen, "<!--- ". md5($webpass) . "--->"); fclose($usergen); echo "Generated! You can view your site under /web/" . $webname . ".html"; } else { echo "The file already exists but you entered the wrong Password.<br> Pressing the \"return\" Button will bring you back without loosing the code you entered."; } } else { $usergen = fopen("web/" . $webname . ".html", "w") or die("Unable to open file!"); fwrite($usergen, $webcode); fwrite($usergen, "<br><!--- ". md5($webpass) . " --->"); fclose($usergen); echo "Generated! You can view your site under /web/" . $webname . ".html"; } echo "<FORM><INPUT Type=\"button\" VALUE=\"Back\" onClick=\"history.go(-1);return true;\"></FORM>"; ?> What it does it pretty simple, you enter some html-code that'll be stored in the "webcode" variable, a password, let's say "apple" in "webpass" and the filename is stored in "webname". On first creation, a html-file is created with the <!--- md5(apple) ---> at it's end, the HTML Tags are needed to hide the string from any visitors. If someone wants to edit the File created before, he also enters "apple". Then the string will be looked up as md5(apple) in the file. If the strings match, it's true and the changes should be saved. Whatever i do, though, i'm allways ending up here if i try to edit an existing file: "The file already exists but you entered the wrong Password.<br> Pressing the \"return\" Button will bring you back without loosing the code you entered."; As i said, i'm a newbie, i'd appreciate any tips and help. Thank you in advance!
  12. The code works but it puts the files into /uploadir/. The users directories go by their email addresses ($email). Using the error reporting it tells me: ! ) Notice: Undefined variable: email in /var/www/html/Lab5/uploadfile.php on line 10 Call Stack # Time Memory Function Location 1 0.0010 129288 {main}( ) ../uploadfile.php:0 Any help is much appreciated!! <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors','1'); session_start(); if ($_COOKIE["auth"] == "1") { $file_dir = "/var/www/html/uploaddir/$email"; foreach($_FILES as $file_name => $file_array) { echo "path: ".$file_array["tmp_name"]."<br/>\n"; echo "name: ".$file_array["name"]."<br/>\n"; echo "type: ".$file_array["type"]."<br/>\n"; echo "size: ".$file_array["size"]."<br/>\n"; if (is_uploaded_file($file_array["tmp_name"])) { move_uploaded_file($file_array["tmp_name"], "$file_dir/".$file_array["name"]) or die ("Couldn't copy"); echo "File was moved!<br/>"; } } } else { //redirect back to login form if not authorized header("Location: userlogin.html"); exit; } ?>
  13. I have a .txt document named bannedIPS.txt that has this in it: 12.326.25.3 192.168.1.1 207.236.2.32 10.218.24.5 and then my php script has this //Gets user's IP $ipaddress = $_SERVER['REMOTE_ADDR']; //List of IPs to block $fh = fopen('UserIP/bannedIPS.txt','a+'); $ipBlockList = array(); $countWhileLoop = 0; while($line = fgets($fh)) { $ipBlockList[$countWhileLoop] = $line; $countWhileLoop++; } fclose($fh); //Determine if user IP is on the list for($i=0; $i<=$countWhileLoop-1; $i++) { //Debug for seeing what $ipBlockList[$i] is echo $ipBlockList[$i]."<br/>"; if($ipaddress==$ipBlockList[$i]) { echo "banned"; exit; } } My IP address is 207.236.2.32 so it should display: 12.326.25.3 192.168.1.1 207.236.2.32 banned but it displays: 12.326.25.3 192.168.1.1 207.236.2.32 10.218.24.5 so, the if statement isn't getting triggered. Why is that? I'v tried: if($ipaddress=="207.236.2.32") { echo "banned"; exit; } and then it works, but if it's the variable, it doesn't. PS. I just started learning PHP today from W3Schools and Google. Edit: Fixed typo
  14. Hello! l was wondering if you might be able to help me. l am trying to find out how to make PHP read a file, and then check if that text is already there, and if so don't re-write it. l'll give out my code for an example. <?php //text file that counts the peeps that visit the site $lne = "line.txt"; $File = "counter.txt"; $handle = fopen($File, 'r+') ; //file open $data = fread($handle, 512) ; //file read $count = $data + 1; //Adds one person :DDDDD fseek($handle, 0) ; fwrite($handle, $count) ; //saves the new person echo 'Count #'.$count; // // // // // // $File2 = "ips.txt"; fclose($handle) ; if (isset($_POST['ip'])) { $ip = $_POST['ip']; $port = $_POST['port']; echo 'Connecting to ' . $ip . ':' . $port; exit(); } $ip = getenv("REMOTE_ADDR"); echo '<br>'.$ip; $handle2 = fopen($File2, 'r+') ; //file open $data2 = fread($handle2, 512) ; //file read fwrite($handle2,"\n" . $ip .':' . $count); //saves the new ip ?> <html> <form method="POST"> <input type="hidden" name="ip"> <input type="hidden" name="port"> </html> lt just re-writes the lP with the new counter, very annoying. l can filter it out with VB but l want it all to be server sided. Thank you for your time ~Papa Beans
  15. This is what I have: mkdir($username); $file=fopen($username."/index.htm","w"); fwrite($file,"<html>"."</html>"); fclose($file); where $username refers to what the user entered for their username. The .php I'm using this code in is merely for a signup process. I'm extremely new to PHP (like, today), so please go easy on me.
  16. Hello, I am trying to read XML file and store in sql table. I got two errors. PHP Warning: XMLReader::open(): Unable to open source data Warning: XMLReader::read(): Load Data before trying to read How to solve it ? THANKS IN ADVANCED. $reader = new XMLReader; $reader->open('filename.xml'); while($reader->read()) { /// }
  17. Hi, Newbie here, but I'm trying! So, I'm trying to read from a file which contains an IP address then, insert that IP address into my code which, then, opens a telnet session. My code is working but when I read the IP address from the file, the PHP code inserts spaces between the numbers and dots in the IP address, so, instead of reading 192.168.1.1 I'm getting 1 9 2 . 1 6 8 . 1 . 1 which telnet wont recognise. Here is the code:- ?php require_once "php-telnet/PHPTelnet.php"; $telnet = new PHPTelnet(); $file = fopen("switchIPs2.txt", "r") or exit ("File not found!"); { while (!feof($file)) { $ip = fgets($file); $result = $telnet->Connect($ip); } if ($result == 0) { $telnet->DoCommand('password'); $telnet->DoCommand('en'); $telnet->DoCommand('password'); $telnet->DoCommand('copy running-config tftp:'); $telnet->DoCommand('192.168.1.2'); $telnet->DoCommand(''); $telnet->DoCommand('end'); $telnet->DoCommand('exit'); } } fclose($file); ?> Please let me know if you require any further information to help me! Your time is very much appreciated. Kind regards, Jamie.
  18. Hey there, I've been dabbling in PHP/MySQL for quite a few years. You'll have to forgive me, most of what I have learned has been self taught and therefore my programming vocab is very limited. That being said I've stumbled on a problem that I just can't figure out. I recently followed a tutorial that taught me how to build a fairly effective photo upload/gallery system for my website. It works just fine when dealing with photos of a small size (less than 1MB) but I keep getting an error with photos that are bigger. I have diligently searched through the code and made all the adjustments I can think of in order to allow larger photos to upload but I can't figure it out. So here is the error that I receive when attempting to upload larger photo sizes: Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in php_parsers/photo_system.php on line 94 ERROR: That image has no dimensions OK. Now for the code. It's pretty substantial so I'll attempt to just include the relevant part. I have commented the offending 'line 94': if (isset($_FILES["photo"]["name"]) && isset($_POST["gallery"])){ $sql = "SELECT COUNT(id) FROM photos WHERE user='$log_username'"; $query = mysqli_query($db_conx, $sql); $row = mysqli_fetch_row($query); if($row[0] > 1000){ header("location: ../message.php?msg=The demo system allows only 1000 pictures total"); exit(); } $gallery = preg_replace('#[^a-z 0-9,]#i', '', $_POST["gallery"]); $fileName = $_FILES["photo"]["name"]; $fileTmpLoc = $_FILES["photo"]["tmp_name"]; $fileType = $_FILES["photo"]["type"]; $fileSize = $_FILES["photo"]["size"]; $fileErrorMsg = $_FILES["photo"]["error"]; $kaboom = explode(".", $fileName); $fileExt = end($kaboom); $db_file_name = date("DMjGisY")."".rand(1000,9999).".".$fileExt; // WedFeb272120452013RAND.jpg list($width, $height) = getimagesize($fileTmpLoc); //OFFENDING LINE 94 if($width < 10 || $height < 10){ echo "ERROR: That image has no dimensions"; exit(); } if($fileSize > 10485760) { header("location: ../message.php?msg=ERROR: Your image file was larger than 10mb"); exit(); } else if (!preg_match("/\.(gif|jpg|png)$/i", $fileName) ) { header("location: ../message.php?msg=ERROR: Your image file was not jpg, gif or png type"); exit(); } else if ($fileErrorMsg == 1) { header("location: ../message.php?msg=ERROR: An unknown error occurred"); exit(); } $moveResult = move_uploaded_file($fileTmpLoc, "../user/$log_username/$db_file_name"); if ($moveResult != true) { header("location: ../message.php?msg=ERROR: File upload failed"); exit(); } include_once("../php_includes/image_resize.php"); $wmax = 8000; $hmax = 9000; if($width > $wmax || $height > $hmax){ $target_file = "../user/$log_username/$db_file_name"; $resized_file = "../user/$log_username/$db_file_name"; img_resize($target_file, $resized_file, $wmax, $hmax, $fileExt); } $sql = "INSERT INTO photos(user, gallery, filename, uploaddate) VALUES ('$log_username','$gallery','$db_file_name',now())"; $query = mysqli_query($db_conx, $sql); mysqli_close($db_conx); header("location: ../photos.php?u=$log_username"); exit(); } Any ideas or help would be greatly appreciated. I've been banging my head on my keyboard for over a week trying to figure this out. Could this be a php.ini issue? Am I doing something wrong with the temp file name? Thanks in advance for your help!
  19. If you view the source for this page http://www.online.watchop.com/s/medias.php?id=op602.mp4 and refresh the page over and over that the filedirect url changes. I was wondering what kind of php is behind this and the code i could use to replicate it.
  20. Right now I have a PHP code which takes a template, changes some things on it, and saves it to the same folder the .php file is in. How do I make it so that I can change where that file is saved? <?php if($_POST['submit']) { $name = htmlspecialchars($_POST['sName']); $ip = htmlspecialchars($_POST['sIp']); $port = htmlspecialchars($_POST['sPort']); $desc = htmlspecialchars($_POST['sDesc']); $finalName = $ip."(".$port.").html"; $writestring = ' <tr> <td class="trank">*</td> <td class="tname"><p class="wrap-tname"><a href="/server/5510">'.$name.'</a></p></td> <td class="tserver"><a href="/server/5510"><img style="border:none;width:468px;height:60px;" src="/uniqueminecraftservers/slist/banners/1.jpg"></a><br>IP: '.$ip.'</td> <td class="ttype"><p class="wrap-ttype">'.$port.'</p></td> <td class="tplayers">2078/3000 </td> <td class="tstatus Online">Online </td> </tr>'; if (file_exists($ip."(".$port.").html")) { echo 'File already exists'; } else { $finalName = $ip."(".$port.").html"; $file = fopen($finalName, "w"); $size = filesize($finalName); fwrite($file, $writestring); fclose($file); echo 'File Saved. Your server is now listed!'; } } $url = "http://www.maytagaclasvegas.com/uniqueminecraftservers/"; function redirect($url){ if (headers_sent()){ die('<script type="text/javascript">window.location.href="' . $url . '";</script>'); }else{ header('Location: ' . $url); die(); } } ?> Thanks! -HeyAwesomePeople
  21. Hey guys, I've searched this and couldn't find a way to do it that works. I'm looking for a form, that has a file upload button and a submit button. Once the user clicks submit, the selected file gets uploaded on the users ftp. I'm using godaddy as my hosting. Does anyone know how to approach this?
  22. Hello all, I'm new to PHP and in a bit of a jam. I have a PHP script that scans a specified folder for all the files in it. All of the files are images. It uses a foreach statement to place them all inside of hyperlinks linked to lightbox to make an image gallery. This works perfectly. Now part two of my gallery project is scanning a different file for videos. I figured it would be pretty easy to edit my existing script and conform it to video. I was wrong. Halfway through rewriting the script I realized that every video has two formats. MP4 and OGG. This will cause every video to be displayed in the gallery twice. Does anyone know how to scan a file for videos and place them on a page without making an embeded video for each format? Below is my code. <?php $videos= glob('videos/*'); natcasesort($videos); foreach($videos as $video) { echo '<video controls tabindex="0">'; echo '<source src="'.$video.'" type="video/mp4;" />'; echo '<source src="'.$video." type="video/ogg;" />'; echo '</video>'; } ?>
  23. Hello. I have a quick question (it's probably easy to solve): why isn't the below code working? <?php $myFile = "testFile.txt"; $fh = fopen($myFile, 'w+'); $theData = fread($fh, 5); fclose($fh); echo $theData; ?> All I get is a blank page. Nothing is displayed, and I'm not sure what to do.
  24. Hello people! I want to know some security features for file upload in PHP. I did read many stuffs, but not all have answered my questions. To start, I am more on front-end than back-end, so I am not a professional in PHP, but I do know several things in PHP (Procedural). I did create a file upload system before, which was to upload image, including security and validation. Anyway, I am planning to create a similar system again but I want to know more on things which I have applied before. Here are my questions: 1/ When validating file formats, which is better, validating by MIME or regular expression? I used regular expression before, because I have read MIME can be changed, even that I am curious. Here is an example of regular expression which accepts only JPG and GIF files: /\.(gif|jpg)$/i 2/ Can we upload file like EXE without affecting the server? I do not want the EXE file to execute now on the server, or simply, if it is infected, it can ruin the server. Is there a solution to tackle this or it is not recommended? Because many file hosting let you upload EX, RAR, ZIP, script formats etc... 3/ What other security measures should I take into account on file upload? All uploaded files will be in a folder, and the user will get their links to download. 4/ This question is not on security but mostly on cron job. Normally, file uploaded will be stored in a folder but not forever on the sever. I want that each 3 days, each file which has been uploaded, is deleted from the folder. I am not saying all files have to be deleted simultaneously, but each file which is more than 3 days. For example, I upload one today, on Sunday it will be deleted. If I upload another one tomorrow, on Monday it will be deleted. For this, a person told me to store the timestamps in a database and the name of the file. How to proceed the deletion with cron job? Thank!
  25. this is the scrip i currently have but i get "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'range,groups,b_m,product_code,desc_1,desc_2,qty,nett_price,goods_value) VALUES (' at line 1" <?php if (isset($_POST['submit'])) { if(is_uploaded_file($_FILES['filename']['tmp_name'])){ $handle = fopen($_FILES['filename']['tmp_name'], "r"); while(($data = fgetcsv($handle,1000,",")) !==false) { $ST=$data[0]; $date=$data[1]; $actual_date=$data[2]; $account=$data[3]; $branch=$data[4]; $customer_name=$data[5]; $i_c=$data[6]; $invoice_num=$data[7]; $category=$data[8]; $order_no=$data[9]; $order_item=$data[10]; $range=$data[11]; $groups=$data[12]; $b_m=$data[13]; $product_code=$data[14]; $desc_1=$data[15]; $desc_2=$data[16]; $qty=$data[17]; $nett_price=$data[18]; $goods_value=$data[19]; $query = "INSERT INTO sales_orders (ST,date,actual_date,account,branch,customer_name,i_c,invoice_num,category,order_no,order_item,range,groups,b_m,product_code,desc_1,desc_2,qty,nett_price,goods_value) VALUES ('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','$data[17]','$data[18]','$data[19]')"; mysql_query($query) or die(mysql_error()); } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo COMPANY_NAME; ?> | Sales Figures Upload Screen</title> <link href="<?php echo ROOT; ?>css/login.css" type="text/css" rel="stylesheet" /> <link type="text/css" href="<?php echo ROOT; ?>css/start/jquery-ui-1.8.7.custom.css" rel="stylesheet" /> <script type="text/javascript" src="<?php echo ROOT; ?>js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="<?php echo ROOT; ?>js/jquery-ui-1.8.7.custom.min.js"></script> </head> <body> <div id="box"> <div id="content"> <h1>Sales CSV Update</h1> <p>Please use a valid CSV file extracted from Exant Exporter.</p> <form method="post" action="uploadsale.php" enctype="multipart/form-data"> <p> <input type="file" name="filename"/> </p> <input name="submit" type="hidden"/> <button tabindex="4" type="submit">Upload Data</button> </form> </div> </div> </body> </html> <?php mysql_close($connection); ?>
×
×
  • 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.