PHP - Problem With Creation Of Files In Linux.
Hey, guys, in the following code, why i cannot see my ~/test.txt file? It seem he is not doing what i want, to create a .txt file with 'is just a test'. I'm using Debian.
<?php $f = fopen("~/test.txt","w+"); fwrite($f,'is just a test'); fclose($f); ?>Thank you! Similar TutorialsI need to copy php files from remote linux (apache) server to windows usb drive.
I am using php windows but the files were created in php under linux.
Do I just download them or do I need to do something to make this work
Hi I have been googling really hard and haven't found any satysfying solution except http://www.phpfreaks.com/forums/php-coding-help/open-and-get-contents-of-a-word-document-with-php/ Do you know any PHP class to play with *.doc (up to 2003) files on Linux server? COM is nice but only on w1ndows Thanks in advance Tom Hello,
I've installed a Debian x64 minimal package and a control panel on my VPS, but after I install the name servers, the domain doesn't reach my VPS's name servers for some reason.
The minimal package comes only with the tools to run the Debian server which means it had no sudo and such.
But previously when I had Centos on before switching to Debian, it did reach the name servers.
Which in this case I suspect that it's a server-side problem, could there be any ?
When I try to connect to the domain it says that the website is not available.
I am using zpanel and the default DNS records that the zpanel generates.
P.S. I tried to find the reason why it doesn't work but I couldn't find any solution, all I found is suggestions to add www A record which also didn't work.
And yes, I did wait 24 hours and even more.
I use my desktop (Windows) to make websites and then once it's completed transfer to my Linux server but I've come across a weird issue. On Windows the file location is like this: C:\Server\Apache\htdocs\RSCEmulation On Linux the file location is like this: /home/rscemulation/public_html Now in those folders I have a folder called 'include', in that I have 2 files: header.php, functions.php In the base folder I have index.php. I then include header.php by using: include "include/header.php"; Then I include functions.php (from header.php) by using: include "functions.php"; Now on Linux this chucks an error, even with "./functions.php" -- I have to use include "include/functions.php" even though I'm already in that directory from the file I'm calling it from, although admittedly the file is being included from the directory below but this works fine on Windows with a base PHP install. This Linux box was given to me and I'm not sure if any PHP settings have been changed or not. I also have a config.php that I keep below the public directory (htdocs or public_html) but it won't let me include it on the Linux server by using "../../config.php" (I've tried all levels ranging from 0-5 with no luck) Can anyone shed some light on this please? I need it to work the same both on the Windows and Linux boxes as I copy and paste the files regularly and it's annoying changing them! Cheers. Hi, I have the following code: Code: [Select] <? Header("content-type: application/x-javascript"); function returnimages($dirname="./windows/prezentare_jpg/") { $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(preg_match('/.jpg$/i', $file)){ echo 'galleryarray['.$curimage.']="'.$file .'";'; $curimage++; } } closedir($handle); } return($files); } echo 'var galleryarray=new Array();'; returnimages(); ?> Ran on windows (xampp 1.7.7, PHP 5.3.8, Apache 2.2.21) it returns the correct alfabetical/numerical order: Code: [Select] var galleryarray=new Array();galleryarray[0]="01.jpg";galleryarray[1]="02.jpg";galleryarray[2]="03.jpg";galleryarray[3]="04.jpg";galleryarray[4]="05.jpg";galleryarray[5]="06.jpg";galleryarray[6]="07.jpg";galleryarray[7]="08.jpg";galleryarray[8]="09.jpg";galleryarray[9]="10.jpg";galleryarray[10]="11.jpg";galleryarray[11]="12.jpg"; Ran on linux (PHP 5.3.8, Apache 2.2.21) it returns an incorrect order: Code: [Select] var galleryarray=new Array();galleryarray[0]="06.jpg";galleryarray[1]="01.jpg";galleryarray[2]="08.jpg";galleryarray[3]="10.jpg";galleryarray[4]="04.jpg";galleryarray[5]="11.jpg";galleryarray[6]="05.jpg";galleryarray[7]="03.jpg";galleryarray[8]="07.jpg";galleryarray[9]="09.jpg";galleryarray[10]="02.jpg";galleryarray[11]="12.jpg"; I need the script to run correctly on the linux server. What could be the problem? What can i try? Hi, I have a strange problem with uploading files. My script was working fine on the test server but since moving to the live server it isn't working. Here is a printout of the FILES variable: Code: [Select] Array ( [file] => Array ( [name] => filename.ppt [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) Does anyone know what the problem might be? The error message that comes back is 'Invalid file'. Code: [Select] function upload_ppt_files() { echo 'print_r($_FILES) = '.print_r($_FILES).'<br />'; global $CFG; if (($_FILES["file"]["type"] == "application/vnd.ms-powerpoint") && ($_FILES["file"]["size"] > 100)) { if ($_FILES["file"]["error"] > 0) { $CFG->message = "Error code:". $_FILES["file"]["error"]; manage_ppt_files(); } else { if (file_exists("../../uploads/" . $_FILES["file"]["name"])) { $CFG->message = $_FILES["file"]["name"] . " already exists."; manage_ppt_files(); } else { move_uploaded_file($_FILES["file"]["tmp_name"], "../../uploads/" . $_FILES["file"]["name"]); $CFG->message = "File uploaded successfully."; manage_ppt_files(); } } } else { $CFG->message = "Invalid File."; manage_ppt_files(); } } Hai, i have a project which is build from mac os and then i transfer all the file to windows and run it. Alot of error showing on windows but none on mac os. I already check the short tag but still alot of problem to run from windows. Anyone know whats the problem?
Hello all I have a script that unzips .gz file but after they are unzipped I can not work with them. I unzip the file and then upload to database. BUT when I upload all I get is record IDs, no actual records. When I download the file and open it all the records are there. Can someone tell me what I am doing wrong? Here is the script. Code: [Select] <?php $files = glob('./gz/*.gz'); foreach ($files as $in_file) { $file_name=(str_replace(".gz", " ", $in_file)); $fp = gzopen($in_file, "r"); $outFile = fopen($file_name,"wb"); while (!gzeof($fp)) { // read/write only up to 10kb per step $content = gzread($fp, "10240"); // write the data (if any) if ($content !== false){ fwrite($outFile,$content,"10240"); } } } fclose($outFile); ?> Thanks All I have created a page for users to upload files, but for some reason end users can't access the files. we are getting an access denied page and every time files get uploaded i have to ftp to the site and change the permissions. is there something i am missing? Thank you in advance. Hello everybody, Hope somebody can help. As the subject says, I'm having encoding problems in my includes files, the "accents" and some special characters don't work. However, they do work in my main HTML. I really don't know what the problem is and how to fix it. Thanks in advance. Hello I am using the code:
<?php When I upload files > 2MB, I get an "Internal Server Error" and in the errors log see "Premature end of script headers:..." No problem with smaller files. I'm running PHP 5.28 and have the following in php5.ini. magic_quotes_gpc = Off log_errors = on display_errors = off memory_limit = 64M post_max_size = 8M upload_max_filesize = 8M max_input_time = 360 max_execution_time = 360 upload_tmp_dir = amd_temp The permissions for the upload folder are set to 755. Here's the code: <?php if ($_SERVER['REQUEST_METHOD'] == 'GET') { ?> <form method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" enctype="multipart/form-data"> <input type="file" name="document"/> <input type="submit" value="Send File"/> </form> <?php } else { if (isset($_FILES['document']) && ($_FILES['document']['error'] == UPLOAD_ERR_OK)) { $newPath = 'updocs/' . basename($_FILES['document']['name']); if (move_uploaded_file($_FILES['document']['tmp_name'], $newPath)) { print "File saved in $newPath"; } else { print "Couldn't move file to $newPath"; } } else { print "No valid file uploaded."; } } ?> Any thoughts on what might be the problem? Thanks. Hello, I have a serious problem with includes So in the past I didn't have any organizing done when creating a website it was just the root and I throw in my files and a folder for the images. Now I am organizing my files something like this http://www.flickr.com/photos/41987677@N03/4926503042/. Now in index.php on the root folder I included the top.php, bottom.html and sessions.php as seen on global folder and inside of top.php and session.php are more includes to files like global.css the javascript files and images like logo and background of the top. now everything worked fine on index.php(root) and displayed everything. Now under the karoobridge folder (index.php) I included the top and bottom files on global now its throwing an error. My question is: is the organization I'm using useless with includes should I stick with just throwing everything on root directory? Can you give me some advice? Sorry if my explanation is confusing but I think you get the idea. I also tried $_SERVER["DOCUMENT_ROOT"] and put that in the index of karoobridge folder to get the top.php, though i got the file the image in top.php didn't appear (I also used $_SERVER['DOCUMENT_rOOT'] for the images) what could be the problem? We are using a FileZilla server for our upload ftp server and we encountered a problem in uploading files. When we upload files 1KB - 1.5MB it will be a success but when we upload a file higher than that an error says: "Filename cannot be empty in C:\wamp\www\gankgame\myaccount.php on line 53" Furthermore, when we upload a file much greater than that like 30MB+ it will not upload but has no errors. Is there any way to configure the upload maximum size? or to fix this errors ? Help us please Our upload code is uploaded . please see the attachment i have mysql community server 5.5 workbench 5.2 php 5.3.8 apache http server 2.2 summary: can i write the same code using less variables for the file name and content? okay so i managed to write a code that creates a filename, and each new filename is 1 higher. colony1 colony2 colony3. it also uses the same mysql query created variable to write idcol as 1 higher in the new file than in the previous written file. however to write the code i had to use a buttload of variables. here is the code, the resultant filename and the resultant content of the created file. is there a way to write such a code with less than 15 variables? the problem seems to be that when writing text to a file, i cannot insert certain characters outside of a variable into the final variable which is put in the $string variable input into the fwrite() function. File Name: Colony$.php where $=the last entry in the idcol column in table coltest. File Code: Code: [Select] <?php $idcol = $; include('Colony0.php'); ?> </body> </html> where $=the last entry in the idcol column in table coltest. Code: Code: [Select] <?php $dbhost = 'localhost:3306'; $dbuser = 'root'; $dbpass = 'root'; $dbname = 'aosdb'; $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $query = "SELECT idcol FROM coltest ORDER BY idcol DESC LIMIT 1"; $result = mysql_query($query); $id = mysql_result($result, 0); $vcol = "Colony"; $vcolp = ".php"; $File = "$vcol$id$vcolp"; $FileHandle = fopen($File, 'w') or die("can't open file"); fclose($FileHandle); $File = "$vcol$id$vcolp"; $myFile = $File; $fh = fopen($myFile, 'w') or die("can't open file"); $idw = "$"; $icol= "idcol"; $ique = "?"; $iphp = "Colony0.php"; $ief = "<"; $ieb = ">"; $irese = "= "; $iresn = ";"; $iii= "include('$iphp');"; $ihtml ="</body> </html>"; $hph = "php"; $string = "$ief$ique$hph $idw$icol $irese$id$iresn $iii $ique$ieb $ihtml"; fwrite($fh, $string); fclose($fh); ?> With the following code i can create an xml file. Code: [Select] <?php $myXML = new SimpleXMLElement("<myroot></myroot>"); $title= $myXML->addChild('title'); $title->addAttribute('number','12'); $titleName= $title->addChild('titleName', 'title1'); $titleLink= $title->addChild('titleLink', 'link1'); Header('Content-type: text/xml'); echo $myXML->asXML(); ?> But when i check the validity of xml file http://www.validome.org/xml/validate/ This error occurs: Can not find declaration of element 'myroot'. I suppose that the problem is missing of !DOCTYPE and !ELEMENT lines. How can i create valid XML documents with PHP automatically?? Is it possible to make it without writing doctype and element types for the whole element types of xml by hand $title, $titleName and $titleLink Thank you Whats is the best way to create a forum using php? Should I use any frameworks? If not is there any guide/tutorial/book that descibe this procedure? Thank you. I am attempting to create an image and I have run into a snag. I want to add both text and another image to the image I am making. Here is the code so far minus unnecessary parts: header ("Content-type: image/png"); $name = $fetch_user['username']; $rank = $fetch_rank['rank_title']; $img_url = 'path''. $fetch_rank['rank_image']; $im = @imagecreatefrompng("$img_url") or die("Cannot Initialize new GD image stream"); // try changing this as well $font = 4; $width = imagefontwidth($font) * strlen($string) ; $height = imagefontheight($font) ; $im = imagecreatefrompng("image.png"); $x = imagesx($im) - $width ; $y = imagesy($im) - $height; $backgroundColor = imagecolorallocate ($im, 255, 255, 255); $textColor = imagecolorallocate ($im, 255, 255, 255); //imagestring ($im, $font, $x, $y, $string, $textColor); imagestring ($im, $font, 100, 10, $name, $textColor); imagestring ($im, $font, 100, 22, $rank, $textColor); imagepng($im); Everything works UNTIL I added in this part: $im = @imagecreatefrompng("$img_url") or die("Cannot Initialize new GD image stream"); Any idea what I am doing wrong? All that comes up is "Cannot Initialize new GD image stream"; and I know the URL's work. Hi, I am wanting to check to see if a folder exists, if not create it. PHP on a windows machine so I would like to know how to handle the folder separators. I am wanting to use a path which includes the drive letter, such as... $foldername ="C:\folder1\images\$checkfolder" I was thinking about using something like this: if(!is_dir($foldername)) mkdir ("$foldername",777); What would be the best way of tackling this using windows paths? I am trying to create a basic image with GD library, but my browser says that the image cannot be displayed because it contains errors... I have no idea why. Here's my code: Code: [Select] switch($_GET['case']){ case "progressbar": header('Content-Type: image/jpeg'); $barWidth = 6; $barHeight = 14; $barPadding = 2; $imageWidth = ($barWidth * 10) + (10 * $barPadding); $imageHeight = ($barHeight + ($barPadding * 2)); $img = @imagecreate($imageWidth, $imageHeight); $imgBorder = imagecolorallocate($img, 0, 0, 0); //imagefilledrectangle($img, 1, $imageHeight -1, $imageWidth - 1, $imageHeight - 1, $imgBorder); $output = "Hello, world!"; imagestring($img, 1, 4, 4, $output, $imgBorder); imagejpeg($img); imagedestroy($img); break; } I have a file called image.php that i use to create images and I use the URL image.php?case=progressbar. |