PHP - Creating Zip File Dynamically
This code works:
// create object $zip = new ZipArchive(); // open archive if ($zip->open('./download/zipfile.zip', ZIPARCHIVE::CREATE) !== TRUE) { die ("Could not open archive"); } but, I want to create the name of the zip file dynamically. The following code does not work ... doesn't give me an error, just doesn't create the zip file: // create object $zip = new ZipArchive(); $thisTime = time(); // open archive $thisZip = './download/'.$thisTime.'_download.zip'; $thisZip_b = $thisTime.'_download.zip'; if ($zip->open($thisZip, ZIPARCHIVE::CREATE) !== TRUE) { die ("Could not open archive"); } thanks in advance oh wise ones. mrsburnside Similar TutorialsWhat I want to do is create a table out of records from a table that shows an image and a radio button under the image (so I would imagine it would be in 2 rows). I want it to have 3 columns across. Here's what I have to get and output the results: $fabricsql = "SELECT * FROM Fabric f, Images i WHERE f.SKU = i.SKU"; //echo $fabricsql; $fabricResult = mysql_query($fabricsql); $i=0; while($fabricAssoc = mysql_fetch_assoc($fabricResult)){ //echo $fabricAssoc['SKU']. "+ ".$fabricAssoc['Name']; echo "<a href=\"\"><img src='../../".$fabricAssoc['ThumbPath']."' alt='".$fabricAssoc['Description']."' width='".$fabricAssoc['ThumbWidth']."' /></a><br /> <input type=\"radio\" name=\"fabricSelect\" value='".$fabricAssoc['SKU']."' id=\"RadioGroup1_".$i."\" /><br /><br />"; $i++; } Any help is much appreciated. I'm not even sure this is the best way to go about this so any suggestions are appreciated. I'm looking for any guidance on how to dynamically create css files. I want users to be able to select colors for fonts/backgrounds, borders, etc. from a form which they will submit and it will create a css file and put it in a certain folder. Can someone point me in the right direction? I was thinking of adding queries using a basic HTML form. To be able to do that I was thinking of having a Query sql table which has all the main create, insert, remove, update, delete and select general syntax into it. The idea is to be able to choose a query based on a HTML select option and add the values to a field, any idea how can you do that dynamically?
I have not created any code for this as I dont know where to start, or what its even called. I am on about trying to create a page dynamically depending on the id which is selected. Parts of the URL will change depending on what id is selected for example: 'http://www.facebook.com/home.php?sk=h. i am wanting to create a video website, where when the thumbnail of a video is clicked, a new page is loaded with that more details of the video and the video itself, and im guessing the url would change to identify the id of the video. I cannot create a page for every video by hand, as i will have many videos and this is not very efficient. I am just after the name of this technique or a pointer to a tutorial for how to achieve this. Thanks, Matlab I am creating a dynamic form in php. And i want to add fckeditor to this dynamic form. so any idea about to add fckeditor to a dynamically creating form in php??? Any Help please??? I am trying to use Google's map API to dynamically create new maps. For example, I would like to be able to make a replica of this page using PHP. I just don't see where in the API it allows you to add all this information, such as adding categories, details, pictures, videos, etc. I've been researching for quite a while, and can't seem to come up with something that is similar to what I'm trying to do. Here is a link I found that shows you how to create maps, but I still don't see how to add all the information that you could if you did it manually! http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#CreatingMaps It would be great if someone can point me in the right direction. Thanks! Hi all, Hope to find you all good. I have the following, which creates a php file. This works fine and without error. However, once created, the content of the page, which is got from the Database, is not showing. <?php include_once('includes/header.php'); if(isset($_POST['new']) && $_POST['new']==1){ if(isset($_POST['submit'])){ $trn_date = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $name = mysqli_real_escape_string($con, $_POST['name']); $description = mysqli_real_escape_string($con, $_POST['description']); $body = mysqli_real_escape_string($con, $_POST['body']); $submittedby = mysqli_real_escape_string($con, $_SESSION["username"]); $sql = "SELECT * FROM pages WHERE name='$name'"; $res = mysqli_query($con, $sql); if (mysqli_num_rows($res) > 0) { $message = '<i class="fa fa-times text-danger"> - A Page already exists with that name!</i>'; }else{ $ins_query="insert into pages (`trn_date`,`name`,`description`, `body`, `submittedby`)values ('$trn_date','$name','$description', '$body', '$submittedby')"; mysqli_query($con,$ins_query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ // Name of the template file. $template_file = 'template.php'; // Root folder if working in subdirectory. Name is up to you ut must match with server's folder. $base_path = '/protour/'; // Path to the directory where you store the "template.php" file. $template_path = 'includes/'; // Path to the directory where php will store the auto-generated couple's pages. $page_path = '../'; // Posted data. $row['name'] = str_replace(' ', '', $_POST['name']); $row['description'] = str_replace(' ', '', $_POST['description']); $row['body'] = $_POST['body']; // Data array (Should match with data above's order). $placeholders = array('{name}', '{description}', '{body}'); // Get the template.php as a string. $template = file_get_contents($template_path.$template_file); // Fills the template. $new_file = str_replace($placeholders, $row, $template); // Generates couple's URL and makes it frendly and lowercase. $page_url = str_replace(' ', '', strtolower($row['name'].'.php')); // Save file into page directory. $fp = fopen($page_path.$page_url, 'w'); fwrite($fp, $new_file); fclose($fp); // Set the variables to pass them to success page. $_SESSION['page_url'] = $page_url; // If working in root directory. $_SESSION['page_path'] = str_replace('.', '', $page_path); // If working in a sub directory. $_SESSION['page_path'] = substr_replace($base_path, '', -1).str_replace('.', '',$page_path); $message = '<i class="fa fa-check"></i> - Page Created Successfully'; } } } } ?> <!-- Header--> <div class="breadcrumbs"> <div class="col-sm-4"> <div class="page-header float-left"> <div class="page-title"> <h1>Pages</h1> </div> </div> </div> <div class="col-sm-8"> </div> </div> <div class="content mt-3"> <div class="animated fadeIn"> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-header"><strong>Add </strong><small>Page <?php if($message = isset($message) ? $message : ''){ printf($message); } ?></small></div> <div class="card-body card-block"> <form role="form" method="post" action""> <input type="hidden" name="new" value="1" /> <div class="modal-body"> <div class="form-group"><label for="name" class=" form-control-label">Page Name</label><input type="text" id="name" name="name" placeholder="name" class="form-control"> </div> <div class="form-group"><label for="description" class=" form-control-label">Description</label><input maxlength="100" type="text" id="description" name="description" placeholder="descriptioon" class="form-control"></div> <div class="form-group"><label for="body" class=" form-control-label">Body</label> <textarea class="form-control" id="body" name="body" placeholder="body"></textarea> </div> <div class="modal-footer"> <button type="submit" name="submit" id="submit" class="btn btn-primary">Confirm</button> </div> </form> </div> </div> </div><!-- .animated --> </div><!-- .content --> </div><!-- /#right-panel --> <!-- Right Panel --> <script src="assets/js/vendor/jquery-2.1.4.min.js"></script> <script src="assets/js/popper.min.js"></script> <script src="assets/js/plugins.js"></script> <script src="assets/js/main.js"></script> <script src="assets/js/bing.js"></script> <script src="assets/js/lib/data-table/datatables.min.js"></script> <script src="assets/js/lib/data-table/dataTables.bootstrap.min.js"></script> <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script> <script src="assets/js/lib/data-table/buttons.bootstrap.min.js"></script> <script src="assets/js/lib/data-table/jszip.min.js"></script> <script src="assets/js/lib/data-table/pdfmake.min.js"></script> <script src="assets/js/lib/data-table/vfs_fonts.js"></script> <script src="assets/js/lib/data-table/buttons.html5.min.js"></script> <script src="assets/js/lib/data-table/buttons.print.min.js"></script> <script src="assets/js/lib/data-table/buttons.colVis.min.js"></script> <script src="assets/js/lib/data-table/datatables-init.js"></script> <script src="https://cdn.tiny.cloud/1/sw6bkvhzd3ev4xl3u9yx3tzrux4nthssiwgsog74altv1o65/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script> <script> tinymce.init({ selector: 'textarea', plugins: 'advlist autolink lists link image charmap print preview hr anchor pagebreak', toolbar_mode: 'floating', }); </script> <script type="text/javascript"> $(document).ready(function() { $('#customer-table').DataTable(); } ); </script> </body> </html> My guess is the placeholder section is not working. // Posted data. $row['name'] = str_replace(' ', '', $_POST['name']); $row['description'] = str_replace(' ', '', $_POST['description']); $row['body'] = $_POST['body']; // Data array (Should match with data above's order). $placeholders = array('{name}', '{description}', '{body}'); Here is template.php <?php include_once('includes/header.php'); require_once('admin/includes/config.php'); if(isset($_POST['new']) && $_POST['new']==1){ $trn_date = mysqli_real_escape_string($con, date("Y-m-d H:i:s")); $name = mysqli_real_escape_string($con, $_POST['name']); $email = mysqli_real_escape_string($con, $_POST['email']); $pickup = mysqli_real_escape_string($con, $_POST['pickup']); $dropoff = mysqli_real_escape_string($con, $_POST['dropoff']); $dep_date = mysqli_real_escape_string($con, $_POST['dep_date']); $ret_date = mysqli_real_escape_string($con, $_POST['ret_date']); $dep_time = mysqli_real_escape_string($con, $_POST['dep_time']); $pax_numbers = mysqli_real_escape_string($con, $_POST['pax_numbers']); $ins_query="insert into quotes (`trn_date`,`name`,`email`, `pickup`, `dropoff`, `dep_date`, `ret_date`, `dep_time`, `pax_numbers`) values ('$trn_date','$name','$email', '$pickup', '$dropoff', '$dep_date', '$ret_date', '$dep_time', '$pax_numbers')"; mysqli_query($con,$ins_query) or die(mysqli_error($con)); if(mysqli_affected_rows($con)== 1 ){ $message = "Thank you. We will be in touch soon."; } } $sql = "SELECT * FROM slide"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { ?> <div class="hero-wrap" style='background-image: url("admin/uploads/<?php echo $row['image']; ?>")' data-stellar-background-ratio="0.5"> <div class="overlay"></div> <div class="container"> <div class="row no-gutters slider-text justify-content-start align-items-center"> <div class="col-lg-6 col-md-6 ftco-animate d-flex align-items-end"> <div class="text"> <p style="font-size: 18px;"><?php echo $row['slide_text']; ?></p> <a href="<?php echo $row['youtube']; ?>" class="icon-wrap popup-vimeo d-flex align-items-center mt-4"> <div class="icon d-flex align-items-center justify-content-center"> <span class="ion-ios-play"></span> </div> <div class="heading-title ml-5"> <span>Play Our Short Video</span> </div> </a> </div> </div> <div class="col-lg-2 col"></div> <div class="col-lg-4 col-md-6 mt-0 mt-md-5 d-flex"> <form method="post" action="" role="form" class="request-form ftco-animate"> <input type="hidden" name="new" value="1" /> <h2>Get A Quote</h2> <div class="d-flex"> <div class="form-group mr-2"> <label for="name" class="label">Name</label> <input class="form-control" type="text" id="name" name="name" placeholder="Your Name" /> </div> <div class="form-group ml-2"> <label for="email" class="label">Email</label> <input class="form-control" type="email" id="email" name="email" placeholder="Your Email" /> </div> </div> <div class="form-group"> <label for="searchBox" class="label">Pick-Up Location</label> <input class="form-control" type="text" id="searchBox" name="pickup" placeholder="Start Typing..." /> </div> <div class="form-group"> <label for="searchBoxAlt" class="label">Drop-Off Location</label> <input type="text" class="form-control" id="searchBoxAlt" name="dropoff" placeholder="Start Typing..." /> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Departure Date</label> <input type="text" class="form-control" id="book_pick_date" name="dep_date" placeholder="Date"> </div> <div class="form-group ml-2"> <label for="" class="label">Return Date</label> <input type="text" class="form-control" id="book_off_date" name="ret_date" placeholder="Date"> </div> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Pick-Up Time</label> <input type="text" class="form-control" id="time_pick" name="dep_time" placeholder="Time"> </div> <div class="form-group ml-2"> <label for"" class="label">Passenger Numbers</label> <input type="number" class="form-control" id="pax_numbers" name="pax_numbers" placeholder="Amount" /> </div> </div> <div class="form-group"> <button type="submit" class="btn btn-primary py-3 px-4">Request Quote</button> <p><?php if($message = isset($message) ? $message : ''){ printf($message); } ?></p> </div> </form> </div> </div> </div> </div> <?php } } ?> <script type="text/javascript" src="https://www.bing.com/api/maps/mapcontrol?key=AqIY0ivSCCdBIe3-EKGuox9cwBFw2wWRWIErZi1iy57EfD67PoiSra9wl_wu48de&callback=bingMapsReady" async defer></script> <?php if(isset($_GET['id'])){ $id = mysqli_real_escape_string($con, $_GET['id'] ?? DEFAULT_ID); $sql = "SELECT * FROM pages WHERE id = $id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_array()) { ?> <!-- HOW IT WORKS --> <section class="ftco-section ftco-no-pt ftco-no-pb"> <div class="container"> <div class="row no-gutters"> <div class="col-md-12 wrap-about py-md-5 ftco-animate"> <div class="heading-section mb-5 pl-md-5"> <span class="subheading"><?php echo $row['description']; ?> </span> <h2 class="heading"><?php echo $row['name']; ?></h2> <?php echo $row['body']; ?> </div> </div> </div> </div> </section> <?php } } } ?> <!-- FOOTER --> <?php include_once('includes/footer.php'); ?> Please note that this is just a project and will not be going live. It's for learning purposes and I am aware there are some vulnerabilities within parts of the code. Any assistance with the above issues though would really be appreciated. Thanks and have a ripper evening. Hi there, I am just wondering which way is the correct one if you want to create object properties/attribute dynamically at run time using magic method __set(), __get(), for example: class Foo{ public $data = array(); public function __set($name,$value){ $this->data[$name] = $value; } public function __get($name){ if ( isset($this->data[$name]) ){ return $this->data[$name]; } } } Or using the below way class Foo{ public function assign(array $data){ foreach($data as $key => $value){ $this->$key = $value; } } } I just encountered the second way in many places and I am totally confused . Is the __set() method called implicitly by the PHP engine in the second way or what? how come this is considered as a valid code ? your usual help is appreciated I have a page using forms to help build listing templates for eBay. I have a folder where I have hundreds of logos stored. I know the logo names but not their extensions. . . . I have to test each potential (jpg, jpeg, gif, png, etc.) until I guess right. Here is an example code for the web form:
<form action="extension_test2.php" method="post"> <p>Logo: <input name="e" value="" type="text" size="15" maxlength="30" /><p> <input name="Submit" type="Submit"/> </form> and the form's result: <? $e =$_POST['e']; if(!empty($e)) { echo '<img src="http://www.gbamedica...ebayimg/logos/'.$e.'">'; }; ?> Here is a link to the example: http://www.gbamedica...ension_test.php Use "olympus.jpg" for test. I am looking for code that can determine the file type and dynamically add the extension. Can it be done? Hey everyone, I'm pretty new to this, not my full time job, but just something I thought I'd give a shot... I have a database, in postgres, in which I make my query and I go fetch all the info I need. What I need to do next is the tricky part for me. For each line of results received, I have to output to a text file (.txt) but I have to respect a format that was given to me from the person requesting the info. Example: Character 1 must be G or N. Character 2 to to 11 will be a result from my database search, which is a 10 digit string. Character 12 to 14 must be spaces. Another rule is: start at character 78: input a value from my database search but it must not exceed 20 characters and if it is less then 20 character, fill the remaining with spaces. If anyways has a code I can copy and work off of I would really appreciate it....thanks! Hi, I want to create a .html file dynamically on the server. Below is the code for that but i was not able to create the file. I have given all the read, write and execute permission on the folder. $filerand = rand(); $fileName = "test.html"; $filepath = $_SERVER['DOCUMENT_ROOT'] . "\\testfolder\\" . $fileName . ".html"; echo $filepath; $bodytxt = "Welcome to my webpage"; $ourFileHandle = fopen($filepath, 'w') or die("can't open file"); fwrite($ourFileHandle, $bodytxt); fclose($ourFileHandle); Thanks in advance Hello I was trying from days to create an array from a txt file by i can't make it happen. I am so desperate now and i want your help guys The code create a txt file from a textarea feild after it's submited each on a line. After that the php code need collect these data from the txt file and create an array from them. Example: if i type in the textarea: test test1 test2 I want these usernames to be inserted in the array so it would be like this: $names = array('test','test1','test2'); Anyone can help me This is the code <html> <head> <title></title> <style type="text/css"> body{ background-color:#1166aa; } #mainbox{ width:inherit; background-color:#FFFFFF; padding:14px; border:solid 3px #000000; float:left; } #mainbox2{ background-color:#CCCCCC; border:solid 2px #000000; padding:11px; } #contaner{ border:solid 0px #00FF00; } h1:hover{ color:#0000CC; cursor:pointer; } #msg{ cursor:pointer; } table td{ border-top:outset 1px #999999; } #amount{ color:#FF0000; cursor:crosshair; } #to{ color:#3300FF; } #from{ color:#3300FF; } #subject{ color:#3300FF; } </style> </head> <body alink="#003399" vlink="#003399"> <?php ///////////////////////////////////////////////// function create_list(){ $list= ($_GET ['name_list']); $file= "list.txt"; $file_pointer = fopen($file ,'w'); fwrite($file_pointer , $list); fclose($file_pointer); } ////////////////////////////////////////////////// $list= ""; create_list(); ////////////////////////////////////////////////// function explodeRows($data) { $rowsArr = explode("\n", $data); return $rowsArr; } $filename = "list.txt"; $handle = fopen($filename, 'r'); $data = fread($handle, filesize($filename)); $rowsArr = explodeRows($data); for($i=0;$i<count($rowsArr);$i++) { $name = explodeRows($rowsArr[$i]); function name(){ $names = array('the usernames submited to be inserted here','the usernames submited to be inserted here',.......); } } //////////////////////////////////////////////////// if ($_GET ['submit'] == "submit"){ create_list(); name(); } ?> <script type="text/javascript"> function foo(textarea,limit){ var val=textarea.value.replace(/\r/g,'').split('\n'); if(val.length>limit){ alert('You can not enter\nmore than '+limit+' lines'); textarea.value=val.slice(0,-1).join('\n') } } </script> <table align="center" id="contaner"> <tr><td> <form action="<?php $_SERVER [SERVER_NAME]; ?>" method="get"> <div id="mainbox"> <div id="mainbox2"> <table> <tr> <td>name List :</td> </tr> </table> <textarea id="name_list" name="name_list" cols="60" rows="9" onkeyup="foo(this,50)"></textarea> </div> <tr> <td><center><input name="submit" type="submit" value="submit"/></center></td> </tr> </div> </form> </tr></td> </table> </body> </html> I am new to Php and the linux environment. I have written a php program which sames a file to folder using xampp in Windows but I am having a problem with the pathway using my Ubuntu server and LAMP. My code I used in Windows was: $fileName = "guessbook.txt"; $file = fopen ($fileName, "ab"); if(!$file) { echo "ERROR! did not create the file! Exiting.<br />; exit(); } This file was saved correctly using xampp into the htdoc folder and worked fine when I called it in my browser. I tried to substitute a Linux pathway ie: /var/www/assignment2/guessbook.txt, where guessbook is in the code but still nothing. Can someone explain how to write the correct pathway to save this file? Thank you Paul Hi all I am having some issues basically Code: [Select] $sftp->put("server.properties", "allow-nether=".$nether." level-name=".$lname.""); is not printing the variables. $sftp is part of the phpseclib and the fuction is in the same format as fwrite(), I have tried and failed using fwrite as well! I can echo out the 1st variable correctly, but as soon as I add the second I just get Code: [Select] allow-nether= level-name= The variables $nether and $lname exist and I have echo'd them to check. I guess this is a formatting problem, just cant work it out! I have the code below , and when I run it on my website , it returns a XML Parsing Error: not well-formed error , which says it has a problem reading the & i think
please see http://www.jamesflow...om/php/xml2.php
I think it has something to wiht the str_replace as when I change the $row['customerName'] . "</Name>\n"; to $row['customerNumber'] . "</Name>\n"; as a test it works fine , I understand XML cant handle special characters , how would prevent this happening?
code as below
$query = "SELECT * FROM customers"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<entries>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<entry>\n"; $xml_output .= "\t\t<Name>" . $row['customerName'] . "</Name>\n"; // Escaping illegal characters $row['text'] = str_replace("&", "&", $row['text']); $row['text'] = str_replace("<", "<", $row['text']); $row['text'] = str_replace(">", ">", $row['text']); $row['text'] = str_replace("\"", """, $row['text']); $xml_output.= "\t\t<Number>" . $row['customerNumber'] . "</Number>\n"; $xml_output.= "\t</entry>\n"; } $xml_output .= "</entries>"; echo $xml_output; regards James Hey guys i've been trying to find out how to create and and write in a file, so that you can for example add a nav button to your website by form (you know like a admin panel). It tried some things but it doesnt work cause it wont write to the file... here is the code i've used: $ourFileName = $_POST['sitename']; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); $myFile = $_POST['sitename']; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "test\n"; fwrite($fh, $stringData); $stringData = "test\n"; fwrite($fh, $stringData); fclose($fh); the "sitename" is the id from the form where you choose what the menu tab should be called. I would really glad if you could help me out with this one thanks! MinG I have a question for developing (or in this case rewriting) an application. The current application creates directories and files (thumbnails, etc..) in a directory of the application files. In order to do this I have to set the directories chmod to 777 via ftp. I know this isn't secure. What exactly do you put in the application's code to allow it to write to a file or directory with CHMOD of 755. From the beginning, the user accesses my website and uploads an image. Currently I'm using SimpleImage.php available at http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php to resize uploaded pictures. I create two copies, a regular size and a thumbnail size. Then I transfer the converted files through FTP to my storage server. The regular size works great, but the thumbnail transfers as a blank file. I don't want to save the files on the non-storage server at all, so I'm trying to work with temporary files. include('./SimpleImage.php'); // A few variables $file_name = basename($_FILES['photo1']['name']); $random_digit=mt_rand(111111111,2147483647); // New file name $new_file_name = $userInfo['id'].'_'.$random_digit.$random_digit.'_'.substr($file_name, -5); // Paths to temporary files $target_path = $_FILES['photo1']['tmp_name']; $thumb_path = tmpfile(); // Start SimpleImage and load temp file $simImage = new SimpleImage(); $simImage->load($target_path); // Get the temp image dimensions list($width, $height) = getimagesize($target_path); // Resize the file if it's too tall if ($height > $var['maxPhotoHeight']) { $simImage->resizeToHeight($var['maxPhotoHeight']); $simImage->save($target_path); } // Get the newly resized image dimensions list($width, $height) = getimagesize($target_path); // Resize the image if it's too wide if ($width > $var['maxPhotoWidth']) { $simImage->resizeToWidth($var['maxPhotoWidth']); $simImage->save($target_path); } // Resize for thumbnail width $simImage->resizeToWidth($var['thumbWidth']); $simImage->save($thumb_path); // Get thumbnail dimensions list($width, $height) = getimagesize($thumb_path); // Resize the thumbnail if it's too tall if ($height > $var['thumbHeight']) { $simImage->resizeToHeight($var['thumbHeight']); $simImage->save($thumb_path); } // Was told this was important, but I've tried with and without it and got the same result fseek($thumb_path,0); // Perform File Transfer ftpTransfer($target_path, "$new_file_name"); ftpTransfer($thumb_path, "thumbs/$new_file_name"); // My Simple FTP Transfer Function: function ftpTransfer($source, $name) { global $ftp; $ftpMeta = "ftp://" . $ftp['user_name'] . ":" . $ftp['user_pass'] . "@" . $ftp['server'] . $ftp['dir'] . $name; $ftpData = file_get_contents($source); file_put_contents($ftpMeta, $ftpData); } Like I said, the regular sized image works great!! the thumbnail file is only created on the storage server but it has a 0kb file size. I'm sure it has to do with me working with a temporary file. tmpfile() claims to remove the file after it's closed, so maybe by using the Save feature in SimpleImage, it's closing the file and then the server automatically removes the temporary file? SimpleImage has a feature where I can write the image output [possibly to a file] using $simImage->output() for the data. If that helps with a solution? I don't know. I know it might be complicated, but any help is appreciated! Yes, I am going to be one of those guys today. I have never done XML anything, besides past 2-3 hours or so, and I am getting frustrated. I have learned how to create simple XML files and save them. I am however having hard time figuring out how to create and XML file when trying to access an table from databse. I am looking to export from "registered_users" table all "registrations" and include "first_name", "last_name" and "age"
Sample:
<registered_users>
<registration>
<first_name>Bob</first_name>
<last_name>Smith</last_name>
<age>36</age>
</registration>
<registration>
<first_name>Jack</first_name>
<last_name>Miller</last_name>
<age>45</age>
</registration>
</registered_users>
It would be nice if the file would be saved as spearate "all_users.xml"
Any help would be appreciated
Hi. I am trying to create a simple video file server. I finished the skeleton of it but when it came to creating the multitude of pages I realized that there could be an easier way to do it.
I started out basically getting the folder names in the server then printing them on the page.
<?php $dirs = glob("*", GLOB_ONLYDIR); echo '<ul>'; foreach($dirs as $dir) { $forbidden_folders = array("not4u", "ignore", Styles); $filename = str_replace($forbidden_folders, '', $dir); if (!empty($filename)) { echo '<li><a href="'.$dir.'">'.$dir.'</a></li>'; } } echo '</ul>' ?>Then I created in each of the folders with files a php file with this code: <?php function date_sort_desc($a, $b) { preg_match('/\w+ \d{4}/', $a, $matches_a); preg_match('/\w+ \d{4}/', $b, $matches_b); $timestamp_a = strtotime($matches_a[0]); $timestamp_b = strtotime($matches_b[0]); if ($timestamp_a == $timestamp_b) return 0; return $timestamp_a < $timestamp_b; } $files = array(); $dir = opendir('.'); while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..") and ($file != "index.php")) { $files[] = $file; } } natsort($files); $i = 0; foreach($files as $file) { $i++; $string = str_replace("TV Show Name S1 E$i - ", '' , $file); echo '<div><a href="../Discriptions/'.$file.'.php">'.basename($string, '.m4v').'</a></div><br>'; } ?>This opens up a php file with the same file name as the file to be played containing the episode's thumbnail and description. That file then contains a link pointing back to the real file. The problem here is that I'd have to make a new php file for every file in my collection. I'm wondering if there's somehow a way to simplify all of this. Edited by chrisyroid, 11 August 2014 - 12:13 AM. |