PHP - Save Webpage
Hi,
I want to save an webpage into my server location, as simple as that. At present, I am reading the content of the file using curl, save that content into a text file, then save that text file. I assume there must be some straightforward way just to save www.example.com/file.html into my server directory as file.html. Can anyone help me on this, please? Thanks, -Abd Similar TutorialsHey guys! I have the following script to create an excel file, the thing is that I dont want to be asked if I want to open or save the file when accessing the php file...I just want the php file directly to save the excel file. Heres the code: $filename = "test.xls"; $contents = "testdata1 \ntestdata2 \ntestdata3 \n"; header('Content-type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename='.$filename); echo $contents; Is there a way instead of using the header function, use something like: fopen, fwrite, fclose ? Thanks in advance! Cheers, try { echo "<br>"; foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) { if($row['picture'] != "" && $row['picture'] != null) { echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>"; } if($row['year'] != "" && $row['year'] != null) { echo $row['year']; } if($row['description'] != "" && $row['description'] != null) { echo $row['description']; } if($row['sold'] == 1) { echo "<img src='images/sold1.png'><br>";//Add your image code here } elseif ($row['sold'] == 0) { echo "</div><br>"; } } } catch (PDOException $e) { print $e->getMessage(); } ?>
good day here! I'm new in php, and i want to save diff array at the same time. is it possible? if (isset($_POST['submit'])) { $user_Id = $_POST['user_Id']; $se_Id = $_POST['se_Id']; $status = $_POST['status']; foreach ($_POST['user_Id'] as $user_Id) <-- this is working, but I want to include the other array { mysql_query("INSERT tbl_data (user_Id,se_Id,status) VALUES ('$user_Id','$se_Id,'$status'')") or die(mysql_error()); } } help me guys. $new_relation->save(); echo "after save".$requestor_profile->getId()." ".$requestee_profile->getId(); return true; }catch(PropelException $e) { echo "in die"; die($e); return false; } }//end - if (!$res) [/PHP] the echo after the save executes but when i look in my db table there is nothing???? please help??? Im trying to use a cropping feature but when the image is cropped the alpha channel is lost. Anyone know where im going wrong here? if($ext == 'png') { $srcImg = imagecreatefrompng('avatars/'.$original); $newImg = imagecreatetruecolor($width, $height); imagealphablending($srcImg, true); imagesavealpha($srcImg, true); imagecopyresampled($newImg, $srcImg, 0, 0, $x1, $y1, $width, $height, $width, $height); imagepng($newImg, 'avatars/'.$user_name.'_avatar_cropped.png'); $link->query("UPDATE ".TBL_PREFIX."users SET u_avatar_cropped = '".$user_name."_avatar_cropped.png' WHERE u_username = '$user_name'") or die(print_link_error()); } I want to save files to a directory. I am using a input type="text" to let user paste directory, then they choose the file from an upload form, then press submit. So here is my script: ============== <form method="post" action="" enctype=...> <input type="text" name="textboxDir" /> <input type="file" name="uploadedFile"/> </form> So how do I now save the uploaded file via $_POST['uploadedFile'] to the text box directory: $_POST["textBoxDir"]? Any help much appreciated! test.php Code: [Select] <?php setcookie("test", 'tester', time()+3600*24*30 , "/", ".mystagingsite1.com"); header('Location: test2.php'); ?> test2.php Code: [Select] <?php echo '<pre>'; print_r($_COOKIE); echo '</pre>'; ?> This does not work. It's not setting the cookie at all. Is there something I am doing wrong here? I have a button that brings up my systems printer....
<button onClick="window.print()">Print this page</button>I'm trying to find a way to do the same thing but giving me the ability to save-as to my CPU. What would be nice is if I could have separate buttons to save-as a PDF and one for CSV. Each would automatically save to a file, with a comfirmation that its saved. The location would be coded in PHP for the desired format, and all the user has to do is click the button and it is placed in the appropriate folded. is this possible and easy to do across ie, firefox and chrome? Thanks for any direction. . Edited by Butterbean, 15 January 2015 - 12:09 AM. What is the best way to capture items that someone wants to purchase when they don't have an account yet? And I prefer not using cookies.
Hello, I want to do, when someone click on button/link will open this: but not Save As, but Open. I know how to make simple form: <html> <body> <form action="edit.php" method="post" enctype="multipart/form-data"> <label for="file">File:</label> <input type="file" name="file" id="file" /> <br><br> <input type="submit" name="submit" value="Open"/> </form> </body> </html> But here You must click Browse, but I want to do like in photo: if You click on button, then at once will open form like photo. Many thanks, Tadas P.S. Sorry for my really bad English. I have html form and verify post data via pgp how can I save someone data if some one fill incorrect information Hi I have a javascript image cropping script which is working well, I then have some php to save the new cropped image. But I can't seem to get it working 100%. When the form is posted the cropped image is not created and I get a "The connection was reset" error. If I comment out the line Code: [Select] $source=imagecreatefromjpeg($image); then I dont get the The connection was reset" error but the image is obviously still not created. Can anyone help? Code: [Select] <?php function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){ list($imagewidth, $imageheight, $imageType) = getimagesize($image); $imageType = 'image/jpeg'; $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); switch($imageType) { case "image/jpeg": case "image/jpg": $source=imagecreatefromjpeg($image); break; } imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height); switch($imageType) { case "image/jpeg": case "image/jpg": imagejpeg($newImage,$thumb_image_name,90); break; } chmod($thumb_image_name, 0777); return $thumb_image_name; } function getHeight($image) { $size = getimagesize($image); $height = $size[1]; return $height; } function getWidth($image) { $size = getimagesize($image); $width = $size[0]; return $width; } $large_image_location = $upload_path.$large_image_name.'.jpg'; $thumb_image_location = $upload_path.$thumb_image_name.'.jpg'; if (isset($_POST["upload_thumbnail"])) { $x1 = $_POST["x1"]; $y1 = $_POST["y1"]; $x2 = $_POST["x2"]; $y2 = $_POST["y2"]; $w = $_POST["w"]; $h = $_POST["h"]; $scale = $thumb_width/$w; $cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale); header("location:index.php"); exit(); } ?> Hi. I have a sort of security script which checks a few things, how can i save the url of the link that was clicked, so i can pass it through the script then if all is good, continue on to the url, if not send them somewhere else let me try to explain better with a little text picture user clicks link ----------------------> link goes to my security script --------------------> if the check passes, continue to original links url so basically i just need to know how to save the links url as a variable This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353684.0 Hi.. Im generating daily reports for employees I have to give PRINT AND SAVE AS PDF button ..how to implement this.. Any code for this in php Thanx in Advance Hey, my code doesnt work and I dont know why: $update_weed_world_data_sql = "SELECT weed_factor, weed_basis FROM worlds"; $update_weed_world_data_res = mysql_query($update_weed_world_data_sql) OR DIE (mysql_error()); while($update_weed_world_data_while = mysql_fetch_assoc($update_weed_world_data_res)){ $update_weed_world_basis[''.$update_weed_world_data_while['id'].''] = $update_weed_world_data_while['weed_basis']; $update_weed_world_factor[''.$update_weed_world_data_while['id'].''] = $update_weed_world_data_while['weed_factor']; } I want to save some rows in variables identifiable by the value in the array. As example. When I want to echo $update_weed_world_factor['1'] - I want to get the row with ID 1 and the column "world_factor". I've used this code long time ago - but know something was going wrong. Thanks for helping :-) I have this code header("Content-type: text/xml"); $database = "rprice"; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT * FROM plist ORDER BY date DESC"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<graph>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<set date =\"" . $row['date'] . "\" value =\"" . $row['sprice'] . "\">\n"; $xml_output .= "\t</set>\n"; } $xml_output .= "</graph>"; echo $xml_output; I want to save this xml file into the folder name Data what is the code of that please help I have my IP camera with the streaming URL :
http://x.x.x.x:81/li...user=admin&pwd=
Now i want to record the streaming using PHP . Now please anyone help how to do this ?
Any help would be appreciated .
Edited by ZohaibKhalid1, 17 October 2014 - 08:41 AM. Hello, I'm editing an XML file using PHP, the XML file contains a playlist of songs for a flash mp3 player. Now I'm able to edit the XML file, but I'm not able to save it . Here's my code: $random_speed = mt_rand(1,15); // Discspeed $song_title = /*mysql_real_escape_string($_GET['song_title'])*/ "My First XML Edit"; $song_artist = /*mysql_real_escape_string($_GET['song_artits'])*/ "A great author"; $song_filename = /*basename(mysql_real_escape_string($_GET['song_filename']))*/ "myfirstxmledit.mp3"; /* Open image directory and get a random image name */ $dir = "./img"; /* Scan the directory and put everything in an array */ $files = scandir($dir); /* Count the elements in the array */ $count_array = count($files); /* Pick a random index from the array */ $rand_array = array_rand( $files, 1 ); /* Pick the value of the random index */ $random_image = $files[$rand_array]; /* Loop through array and if element is not equal to "." or ".." then set the random_image variable */ if( ($random_image == "." ) || ($random_image == ".." ) ){ while( ($random_image == "." ) || ($random_image == ".." ) ){ $random_image = $files[$rand_array]; } }elseif( ($random_image != "." ) || ($random_image != ".." ) ){ echo $random_image; } /* Open the music.xml file */ $xml = new DOMDocument('1.0', 'utf-8'); $xml->formatOutput = true; $xml->preserveWhiteSpace = false; $xml->load('music.xml'); /* Begin settin new element to music.xml file */ $newItem = $xml->createElement('song'); $newItem->appendChild($xml->createElement('title', "'$song_title'")); $newItem->appendChild($xml->createElement('artist', "'$song_artist'")); $newItem->appendChild($xml->createElement('url', "songs/'$song_filename'")); $newItem->appendChild($xml->createElement('image', "img/'$random_image'")); $newItem->appendChild($xml->createElement('discspeed', $random_speed)); /* Add the new elements to the xml tag 'song' */ $xml->getElementsByTagName('song')->item(0)->appendChild($newItem); /* Save the xml file */ $xml->save(); I've tried to enter the filename in the last $xml->save() function, didn't work, added the location + filename, didn't work ... Anyone knows what or how do I save the file? Thanks! |