PHP - Readfile() Read Html File
I'm trying to use the readfile() function to read a html page which has a video embedded (.swf file).
When I call the function, it seems like it just loads the html file but without the dependent files (css,js, etc) When I call it directly it loads just fine. Created a hyperlink 'openvideo.php?id=video' that calls this function below: if($_REQUEST['id'] == 'video') { readfile('/usr/home/site.com/htdocs/content/videofolder/video.html'); } else { echo 'nada'; } Any help is appreciated. Similar TutorialsI am using a photo scrolling css animation technique
I'm not sure as far as CPU usage (on server)/(on client) and bandwith usage if loading one picture at a time to scroll versus having a line up "pre-exist" which even then, I would only have five images at a time but what if that is multiplied by 10000 users
Anyway, the current knowledge I have, I have a css animation property that takes in a photo and animates from 0% to 100% keyframe based on margins to make the scrolling happen
In the HTML section there is a list of photos, I would like there to be one line of code that is like a receiver that takes in or reads in arbitrary photo locations and puts that next to be scrolled without interrupting the main animation sequence which I'm not sure if there would be interruption. Anyway I don't know if that is possible. If someone can point out that this idea is obviously flawed then that would be great.
This isn't my ultimate solution, I have yet to see others, I'm just trying to minimize loading and lag
The other problem I have that is interesting is that I want the scrolling to stop when a person hovers over an image, and then resume... I have gotten this to work but only on one image... this is probably a matter of listing out all the key parts of the problem and seeing the solution but
When I had a list of photos that were scrolling together, I could get the whole animation to stop when hovering over the first photo and then take me somewhere (all the photos have working href's) but the animation would not stop if I hovered over any photos after the first. The animation would keep going
So I tried to animate each picture independently and that was just a cluster ****
Still working on that
If someone could point me in the right direction on the main problem of reading in photos live to work with css animation, that would be great.
Edited by greenace92, 03 December 2014 - 07:41 PM. Hi all, Yesterday I transferred my hosting to a new provider. Everything is up and running apart from the following message I get on my index page Warning: readfile() [function.readfile]: Filename cannot be empty in /home/XXXX/public_html/imgsize.php on line 64 . This error is only on the index page. When I look at line 64 it states the following: readfile ($img); I have tried replacing the imgsize.php file but that still does not work. And on my old hosting this error does not occur. If you could please help, I would appericate it. Cheers Steve In a PHP file [php_one.php], I wrote some PHP code that contained a form. I used ECHO to write the HTML inside of the PHP tags. On another PHP page [php_two.php], I wanted to show the code that was used to create the first page [php_one.php]. My first effort provided an interesting result, since the PHP code was readable. However, all HTML code was visible in its executed form. There was an actual input field and a submit button (not the code used to produce them) in the context of my coding. I have tried using:
file_get_contents("FILE") All results were similar and carried the same problem. How can I view code so that even the HTML is visible as code? I am creating a series of PHP scripts that allow for someone to append extra information to an Accident Claim Report. One of these scripts lists the files in a directory called the RCM directory. For the purpose of this, there is only one file in the list named "denman2.txt" and a hyperlink is attached to it so that the updated Accident Claim Report can be displayed. However, I would like it so that a style sheet could be applied to the "denman2.txt" text file, and I was wondering how it would be possible for the "denman2.txt" file to be opened in a format such as an HTML format so that a style sheet can be applied to it. Here is my Append Code: Code: [Select] <html> <head><title>Amend File</title></head> <?php if($_POST['append'] !=null) { $filename="C:/xampp/htdocs/rcm/denman2.txt"; $file=fopen($filename, "a"); $msg="Updated Information: " .$_POST['append']. "<br>"; fputs ($file, $msg); fclose($file); } ?> <body> <h1>Do you want to append to a document?</h1> Enter Updated Information: <form action="amendfile2.php" method="post"> <input type="text" size="40" name="append"><br><br> <input type="submit" value="Add updated information to report"> </form> <form action="viewfile3.php" method="post"> <input type="submit" value="View Web Blog"> </form> </body></html> My View File Code: Code: [Select] <html><head> <title>RCM File List</title></head> <body> <h1>Files in RCM Directory</h1> <?php $dir="C:/xampp/htdocs/rcm/*txt"; foreach(glob($dir) as $file) { $list = "<li><a href='readfile2.php'>Filename: $file</a></li>"; } ?> <ul> <?php echo $list; ?> </ul> </body> </html> And my Read File Code: Code: [Select] <html><head><title>Reading Accident Reports</title></head> <body> <?php function myErrorHandler($errno, $errstr) { echo "<b>Error: </b> [$errno] $errstr"; echo "<br>"; echo "End scripting"; die(); } set_error_handler("myErrorHandler"); $filename="C:/xampp/htdocs/rcm/denman2.txt"; $file = fopen($filename, "r"); while (!feof($file)) { $line=fgets($file,1024); echo "$line<br>"; } fclose($file); ?> </body> </html> Any help is appreciated I am using apache web server on linux. I am using PHP for web designing. On web server, i want to show the configuration data by reading the ini file. I am creating this ini file from one php code itself. If this php code i run through linux terminal, the file is created with file and group owner as root.(i am having sudo rights on machine) Then if i try to read the ini file from my apache web server, it gives warning as failed to open stream: permission denied. I have tried changing the owner, and permissions to 777 of the file. Still it is not readable.
On the other hand, if i run the php code of ini file creation through web server, ini file is created with file and group owner as apche. and web server is able to read/ write the file.
But i want to create that file from root or some other user and later read/written by apache.
How to give this access permission?
[LIST=1] CSV File Reading Displaying CSV file: Clicking the Show Logfile.txt link at the top of the page should display the CSV records inside logfile.txt Displaying CSV records formatted : Clicking the Show logfile.txt Formatted should display the CSV records formatted in an HTML table is descending order (more recent records are at the top). Use this function to convert CSV records back to an array : fgetcsv() I have most of this done and the problem I'm having is trying to read what I put into the file. (I hard coded what should go into the file). Could you tell me what I'm doing wrong and what I should do to fix it? Code: [Select] <? if ($_POST['_act'] = 'csv'): $fp = fopen('logfile.txt', 'a'); while (($data = fgetcsv($fp, 1000, ",")) !== FALSE){ print_r($data); } fclose($fp); endif; if ($_SERVER['REQUEST_METHOD'] == 'POST'): if (empty($_POST['fullname'])): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; if (ereg("'Mr\. '", $_POST['fullname']) == false): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; print_r($errMsgs); echo count($errMsgs); if (count($disperrMsgs > 0)): $dispErrMsgs = true; else: $fp = fopen('logfile.txt', 'a'); $fputcsv($fp, array("test", "lol", "roool")); fclose($fp); $dispSuccessMsg = true; endif; endif; ?> <html> <head> <style type="text/css"> h1 {color:red} div.error {border: 1px solid red; margin: 20px; padding: 20px; width: 400px} table {border: 1px solid #CCC; margin: 20px; border-collapse: collapse;} td, th {border: 1px solid #DDD; padding: 2px} th {background-color:#363; color: white} td.error {color:red} div.success {border: 1px solid green; margin: 20px; padding: 20px; width: 400px; color:green} </style> </head> <body> <h1> Form Validation Lab with Reg Expressions </h1> <p><a href="<?= $_SERVER['PHP_SELF'] ?> ">Refresh This Page</a> | <a href="./logfile.txt">Show Logfile.txt</a> | <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=csv">Show logfile.txt Formatted</a> <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=clear">Clear logfile.txt </a></p> <? if ($dispErrMsgs): ?> <div class="error"> <p>There are errors in the code: </p> <ol> <? foreach($errMsg as $errMsgs ): ?> <li><?= $errMsgs ?></li> <? endforeach; ?> </ol> </div> <? endif; ?> <? if ($dispSuccessMsg): ?> <div class="success"> <p>Thank you for your submission. </p> </div> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" name="getstuff" method="post" > <input type="hidden" name="_act" value="post"> <table cellspacing = "0"> <tr> <th width="78">Full Name:</th> <td width="184"><input name="fullname" type="text" class="textbox" value="<? $_POST['fullname']; ?>" size="20" ></td> <td width="626" >Salution of Mr. or Mrs. followed by two text strings separated by any number of spaces. </td> </tr> <tr> <th>Street:</th> <td><input name="street" type="text" class="textbox" value="<? $_POST['street']; ?>" size="30"></td> <td >2 or 3 digit number followed by a text string ending with Street or Road separated by any number of spaces. </td> <tr> <th>Phone:</th> <td><input name="phone" type="text" class="textbox" value="<? $_POST['phone']; ?>" size="20"></td> <td >10 digits, first 3 digits have optional parentheses, either side of digits 456 are optional space, dot or hyphen. </td> </tr> <tr> <th>PostalCode:</th> <td><input name="postcode" type="text" class="textbox" value="<? $_POST['postcode']; ?>" size="8" maxlength="8"></td> <td > Postal Code: Char Char Digit Hyphen/space Char Digit Digit (No XYZ or 0's. Case insensitive. )</td> </tr> <tr> <th>Email:</th> <td><input name="email" type="text" class="textbox" value="<? $_POST['email']; ?>" size="25" maxlength="40"></td> <td > Must accept as a minimum : a@b.com</td> </tr> </table> <input name="reset" type='button' class="button" value='RESET' onClick="location.href = location.href"> <input name="_submit" type="submit" class="button" value="Submit me now!!!" > </form> <p id="notice">Everything below here is for testing purposes Don't remove this from your lab as I will use these buttons to fill your form with good and bad data as I mark it.</p> <script> az=document.getstuff; function goodstuff(){ az.fullname.value=" Mr. Joe Smith "; az.street.value="135 Fennell Road "; az.phone.value="905-575.1212"; az.postcode.value="Ln9-T23"; az.email.value="jsmith@gov.ca"; } function goodstuff2(){ az.fullname.value=" Mrs. Josephine Smith "; az.street.value=" 13 Fennell Street"; az.phone.value=" (905)-575.1212 "; az.postcode.value=" Ln9 T23"; az.email.value=" jsmith@gov.ca "; } function badstuff(){ az.fullname.value="Miss Josephine Smith"; az.street.value="1 Somewhere Avenue"; az.phone.value="905575122"; az.postcode.value="Z8N 3T2"; az.email.value="jsmith$gov#ca"; } function badstuff2(){ az.fullname.value=" Joe Smith "; az.street.value=" 1392 Fennell Street"; az.phone.value="[905] 575-1212"; az.postcode.value=" Ly9 T20"; az.email.value=" @jsmith$gov#ca"; } function goodandbad(){ az.fullname.value="Mrs. Joe"; az.street.value=" 135 Fennell Avenue West"; az.phone.value="905:5751212"; az.postcode.value=" L99-T23"; az.email.value=" jsmith@.gov.ca "; } </script> <form> <input type=button class="button" onClick="goodstuff();" value="Fill form with good values " length=100 > <input type=button class="button" onClick="goodstuff2();" value="Fill form with good values 2 " > <input type=button class="button" onClick="badstuff();" value="Fill form with BAD values "> <input type=button class="button" onClick="badstuff2();" value="Fill form with BAD values 2 "> <input type=button class="button" onClick="goodandbad();" value="Fill form with Good and BAD values 2"> <br> </form> </BODY> </HTML> Hi there, I have an xml file which actually hold the currency conversion information which I downloaded from xe.com In the xml, the currency section snapshot looks like this: <currency> <csymbol>EUR</csymbol> <cname>Euro</cname> <crate>0.713</crate> <cinverse>1.403 </cinverse> </currency> this is the conversion of USD to Euro. And it tells how much is 1USD gonna be in Euros. i.e 1 USD = 0.713 EUR I have a product page on my website having the rates shown in USD. For the visitor is accessing the page from Europe it has to show the converted price in Euros. My application can detect the visitors country if hes accessing the page from Europe so that is not a problem. I just need to read the xml file and display the converted price based on the rates in the xml file. How can I read the xml file and output the price in Euros based on the rate. Thank you. All comments and feedbacks are always welcome how can I make php read a file with ids in the format 23423423 32423423 23423454 56667777 and output each id to $id[]? Hello, I'm trying to read the first line of some large files by PHP, which means, the ideal solution does not work: Quote $content = file($file_import); $fields = explode(",", $content[0]); Quote Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 110 bytes) in C:\wamp\www\exchange\admin\import.php on line 55 Is there any other way to read only the first line without opening the whole file? Thanks!! I need some assistance in trying to resolve some issue I have with some code. Currently when I click on an upload button, this should read my csv file and the put the data into phpmyadmin but after looking around various forums and websites I still can not seem to get this to work any assistance would be appreciated. <?php $db = new mysqli('localhost','root','',''); if ($db->connect_errno) { echo "Failed to connect to MySQL: " . $db->connect_error; exit(); } ?> <t<html> <head> <title>Local Care Direct </title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" crossorigin="anonymous"></script> </head> <body> <form method="POST" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>"> <div align="center"> <p>Select CSV file: <input type="file" name="file" /></p> <p><input type="submit" name="csv_upload_btn" value="Upload" /></p> </div> </form> <table align="center" width="800" border="1" style="border-collapse:collapse; border:1px solid #ddd;" cellpadding="5" cellspacing="0"> <thead> <tr bgcolor="#FFCC00"> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> <th>test</th> </tr> </thead> <tbody> <?php // Create database $sql = "CREATE DATABASE IF NOT EXISTS csv"; if (mysqli_query($db, $sql)) { echo "Database created successfully";//confirmation message } else { echo "Error creating database: " . mysqli_error($db);//error message and reason mysql or php mysqli_close($db); } //define the database to use $sql = "Use `csv`"; if (mysqli_query($db, $sql)) { echo " Use csv successfully";//confirmation message } else { echo " Error use csv: " . mysqli_error($db);//error message and reason mysql or php mysqli_close($db); } //create the table in the database $sql = "CREATE TABLE IF NOT EXISTS`csvfile` ( `Test` varchar(10) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(77) DEFAULT NULL, `Test` varchar(4013) DEFAULT NULL, `Test` varchar(16) DEFAULT NULL, `Test` varchar(16) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(16) DEFAULT NULL, `Test` varchar(22) DEFAULT NULL, `Test` varchar(16) DEFAULT NULL, `Test` varchar(22) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test`varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` varchar(10) DEFAULT NULL, `Test` int(8) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL, `Test` varchar(5) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; "; if (mysqli_query($db, $sql)) { echo " table created successfully";//confirmation message } else { echo " Error creating table: " . mysqli_error($db);//error message and reason mysql or php mysqli_close($db); } //in case of data already in the csvtable, delete the data $sql = "DELETE FROM `csvfile`"; if (mysqli_query($db, $sql)) { echo " deleted data from the table successfully "; //confirmation message } else { echo " Error deleting data from the table: " . mysqli_error($db); //error message and reason mysql or php mysqli_close($db); } //do not delete //Process form if(isset($_POST["csv_upload_btn"])) $file = fopen("csv3.csv","r")or die("Failed to read file"); print_r(fgetcsv($file))== NULL; for ($i = 0; $row = fgetcsv($file); ++$i) { } fclose($file); /* $db->query('INSERT INTO `csvfile`(`Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`, `Test`) VALUES ("'.$row[1].'","'.$row[2].'","'.$row[3].'","'.$row[4].'","'.$row[5].'","'.$row[6].'","'.$row[7].'","'.$row[8].'","'.$row[9].'","'.$row[10].'","'.$row[11].'","'.$row[12].'","'.$row[13].'","'.$row[14].'","'.$row[15].'","'.$row[16].'")'); if($n>1){ */ ?> <tr> <td><?php echo $row[0];?></td> <td><?php echo $row[1];?></td> <td><?php echo $row[2];?></td> <td><?php echo $row[3];?></td> <td><?php echo $row[4];?></td> <td><?php echo $row[5];?></td> <td><?php echo $row[6];?></td> <td><?php echo $row[7];?></td> <td><?php echo $row[8];?></td> <td><?php echo $row[9];?></td> <td><?php echo $row[10];?></td> <td><?php echo $row[11];?></td> <td><?php echo $row[12];?></td> <td><?php echo $row[13];?></td> <td><?php echo $row[14];?></td> <td><?php echo $row[15];?></td> <td><?php echo $row[16];?></td> <td><?php echo $row[17];?></td> <td><?php echo $row[18];?></td> <td><?php echo $row[19];?></td> <td><?php echo $row[20];?></td> <td><?php echo $row[21];?></td> <td><?php echo $row[22];?></td> <td><?php echo $row[23];?></td> <td><?php echo $row[24];?></td> <td><?php echo $row[24];?></td> <td><?php echo $row[26];?></td> <td><?php echo $row[27];?></td> <td><?php echo $row[28];?></td> <td><?php echo $row[29];?></td> <td><?php echo $row[30];?></td> <td><?php echo $row[31];?></td> <td><?php echo $row[32];?></td> <td><?php echo $row[33];?></td> <td><?php echo $row[34];?></td> <td><?php echo $row[35];?></td> </tr> <?php //} //++; //} //fclose($handle); ?> </tbody> </table> </body> </html> Before I upload the file I get the following errors
The uploaded file contains dates, time, blank fields, true and false and text. I will need to prevent sql injection and html entities like ampersand sign. After uploading the file, it only reads the first line of my csv file which contains the title of each column and nothing is put into phpmyadmin I have a script which creates a Thumbnail image if one does not exists, the problem is i keep getting this error: Catchable fatal error: Object of class SimpleImage could not be converted to string in /homepages/22/d378569747/htdocs/scripts/primary_image.php on line 21 i have checked the logs and i think its a read error because the the image is already in use by the server if i remove (!file_exists("$root/thumnail_user_images/$image")) the script work fine, is there anyway to stop this error occuring? <?php //header('Content-Type: image/jpeg'); $root = $_SERVER['DOCUMENT_ROOT']; require("$root/include/mysqldb.php"); //mysql login details require("$root/include/mysql_connect.php"); //mysql connect $uin = $_GET['uin']; $result = mysql_query("SELECT * FROM Reg_Profile_images WHERE UIN='$uin' AND `primary` = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $image = $row[2]; if (!file_exists("$root/thumnail_user_images/$image")) { require("$root/include/image_resizing_function.php"); //create image $image = new SimpleImage(); $image->load("$root/raw_user_images/$image"); $image->resizeToWidth(250); $image->save("$root/thumnail_user_images/$image"); $image->output(); } else { readfile("$root/thumnail_user_images/$image"); } } //End Image file ?> Hi, I have a Excel File Reader script that works perfectly on my private development hosting, the Excel file is read and then the contents are displayed to the page with the help of a for loop. The trouble is when I try it out on my work's hosting space the script does nothing, no error messages or anything. I have not changed anything and all paths ect are correct. What else could be causing this? Many Thanks, im looking for a cool code to read file content of a file in a remote server i have a file called online.php that have this commands <?php echo (exec('netstat -a -n |find "5816" |find "ESTABLISHED" /c')-2); ?> i wanna have another file in my own host to read the content of this file from the remote server anyone have an idea ? I am looking for a way to upload a csv file to a website and have it populate a database. Does anyone know of a way to do this. The users of the site are novice website users and I am a novice php coder. Any help would be hugely appreciated. Thanks First, my goals: - The user selects a text file on their local PC (or their local network drive) to process. - I want to read the file into an array and process it. I'm having trouble with this. Here is my code so far: <?php session_start(); $title='Import File v.10a'; ?> <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo '<title>'.$title.'</title>'; ?> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php require_once('navmenu.php'); echo '<h2>'.$title.'</h2>'; ?> <!-- comment --> <?php // Connect to the database $dbc = mysqli_connect($host, $user, $password, $database); $errcnt=0; $models=array(); //Init array $bullarr=array(); $model=''; $partname=''; $partsubname=''; $image=''; $ptype=''; //Product type in {type} tag. if (isset($_POST['cmdImport'])) //Save records that were changed. { $filename=$_POST['txtFilename']; //File on user's machine. $s='You are importing '.$filename; crDebug($s); //DEBUG if (move_uploaded_file($_FILES['txtFilename']['tmp_name'], 'upload/')) { $filename=$_FILES['txtFilename']['name']; $s='Received '.$filename; crInfomsg($s); } else { $errmsg='File upload failed. Error is '.$_FILES['txtFilename']['error']; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$errmsg,true); } if (!(file_exists($filename))) { $errmsg='File '.$filename.' does not exist. Cannot continue.'; crError($_SERVER['PHP_SELF'].' line '.__LINE__,$errmsg,true); } else { } } //if isset($_POST['cmdImport'] ?> <!--------------------------------------------------------> <form action="<?php echo $_SERVER['PHP_SELF'].'?'.SID; ?>" method="post"> <hr/> <label for="cbxBrand">Pick one Brand</label> <?php $oldbrandarr=array(); //Init array. //Do query and loop here. //Show brands from zzbrands. $query = "SELECT bzz ". "FROM zzb ". "ORDER BY br ". ";"; //crInfomsg($query); //DEBUG crCreateSelect($query, 'cbxBrand', 'brand') ?> <p>Input file: <input type="file" name="txtFilename" id="txtFilename" value="" size="80" /> <br/><input type="submit" value="Import" name="cmdImport" /> </form> </body> </html> My problem is I get an error each time "File upload failed" which is displayed above when I try to do move_uploaded_file(). I'm not experienced processing text files. Can someone help me or point me to a website? One more thing, the subdir "upload" is located at the same level as this php file. That is where the uploaded files will go temporarily. Hi All, sure this is simple but I'm still new to php/mySQL so errors are abundant! I have a simple form with one input: a browse button so the user can find a .csv file on their computer. User then clicks button, upon which I would like the file to be read and the contents put into an array, and the values to be added to the database. I do not need the file to be stored (uploaded). So far my code is not erroring, it just doesn't add the values to the db. I'm wondering if it's just that I HAVE to upload and save the file to the webserver else I can't read it? if(isset($_FILES['file_path']['tmp_name'])&& $_FILES['file_path']['tmp_name'] !=''){ $file_to_import = $_FILES['file_path']['tmp_name']; $import_data = file($file_to_import); print_r($import_data); if ($import_data !=''){ for($index = 1; $index < sizeof($import_data); $index++){ $order_data = explode(",",$import_data[$index]); tep_db_query("UPDATE orders SET act_shipping_cost = '" . $order_data[8]. "' WHERE orders_id = '". $order_data[0]."'"); echo "done it"; } }else{ echo 'error cant read file!'; } } else{ ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> etc etc etc <form id="shipping_costs_upload" name="csv_file_reader" method="post" action="shipping_cost_upload.php"> <div class="main" id="info_text"><h2>Upload Actual Shipping Costs CSV</h2><p>To upload actual shipping cost data, browse to your csv and click the Upload Data button.<br /><br /></p> <div class="date" id="file"> <strong>CSV File: </strong><input type="file" name="file_path" id="file_url" /> </div> <div class="date"><input type="submit" value="Upload Data"> </div> </form> etc etc etc Apologies if I'm being a complete dunce! Hi, I want to read image file and write in to word document file using php. Actually i am developing shopping cart site. for that i have created barcode image. i need to take print outs. for example if i click print means same barcode should be generate 64 times in word document. how i do it? i have tried with COM. please check the following code <?php // starting word $word = new COM("word.application") or die("Unable to instantiate Word"); echo "Loaded Word, version {$word->Version}\n"; //bring it to front $word->Visible = 1; //open an empty document $word->Documents->Add(); //do some weird stuff for($i=1;$i<=64;$i++) { $word->Selection->InlineShapes->AddPicture("D:\Program Files\wamp\www\b.jpg ",false, True); } $word->Documents[1]->SaveAs("D:\Program Files\wamp\www\Uselesstest.doc"); //closing word $word->Quit(); //free the object $word = null; ?> It works fine in local. but it is not working in server (it says COM.class is missing). i have checked some forums they said it works with MS based operation system. i have checked with windows only. Please kindly any one help me asap the way for read and write image file in word document. can we do this any other way? we are reading and writing txt files using php the same can we do with image file (read and write in word document) ?? Thanks Prema Hello, Is it possible to read the content of an excel file with file_get_contents. I tried it a couple times. The result looked like this: ������������������������������������������������������������������������������������������������������������������������������������Oh��+'��0�8@Td p|�WorkshopJohn@�v����@��p�������՜.��+,�D��՜.��+,�$�HPX`hp x�� HuidcoachHuidcoach en spec. in huidverbSheet3 f2�ـ����\pJohn B�a�=���=�?�8�@�"��1���A And if it's possible can somebody tell me what i'm doing wrong. Thanx I'm trying to read in a file which is essentially a csv. (I have a couple of books and am a n00b faffing with sessions/cookies etc and am trying to set up an app for a local forum I'm involved with...) I originally tried fgetcsv and also reading the file in line by line (via fgets/explode) and for the most part it works. However some of the entries have a '<' character within them and whenever the script hits a line with one of these it screws up and truncates the line. I presume the '<' is attempting to redirect the data somewhere(?), but have found no way of being able to read this in whole as of yet and I dont really want to resort to processing each line character by character... An example line would be: 3p!<ph4il,Fabulous Diamond Eyes,Lizzies,Div 3C I welcome some advice to put me out of my misery on the matter i have a log file which gets new data time by time. is there any way i can read only new added entries (block) in the file? instead of start reading file from start to the end of file. this file size will be in GBs soon. Thanks. currently i am using file() to read the file. following is the example of new added block in file.
----SMS_START----
recv_time:2014-10-09 18:32:39 Span: 1 From-Number: +1347XXXXXXX Timestamp: 14/10/09 18:32:16 96 Type: PDU SMS-SMSC-Number: +12404492163 Content: Thanks, ----SMS_END---- |