werty37
Members-
Posts
49 -
Joined
-
Last visited
Never
Everything posted by werty37
-
Ah yes! That is a good idea. I ll try to implement it. Thanks a lot for the suggestion... Cheers Sujith
-
Hi Rhodesa, I am using json_d/encode() functions instead of un/serialize() and it does the job quiet well. I dont know why it wouldnt work for me. I am using PHP 5.2.3 on ubuntu (Apache/2.2.4). Thanks Sujith
-
Hi Just a reminder. Simplexml returns objects instead of strings/integers or mixed values. echo is_object($xml->file->allowedfiles); // will print 1 That is why i do type cast before i print echo unserialize((string) $xml->file->allowedfiles); //doesnt print any output I think the problem has something to do with this behaviour. or maybe i have found a bug in php
-
Hi Barand, $xml = simplexml_load_file('conf.xml'); echo (string) $xml->file->allowedfiles; //prints out the serialized data $data = unserialize((string) $xml->file->allowedfiles); echo '<pre>', print_r($data, 1), '</pre>'; // dosent print anything It outputs nothing. The < pre > tag is printed but not the unserialized content.. Sujith
-
Hi Barand, Sorry the code i posted had errors. I did try echo unserialize((string) $xml->file->allowedfiles); //doesnt print any output which ofcourse does not work. Thanks Sujith
-
HI Can anyone help me out with this please. I am trying to print out serialized data stored in a xml file using simplexml. $xml = simplexml_load_file($conf); echo (string) $xml->file->allowedfiles; //prints out the serialized data unserialize((string) $xml->file->allowedfiles); //doesnt print any output Thanks Sujith
-
Hi There are no spaces around <?php ?> tags.... Didnt help
-
Hi I guess you might have to change your logic a bit. You can create a temp table to hold the values and then move the data to the actual "members" table once the userid is confirmed. Hope that helps Regards
-
Hi ILYAS415, I am trying to create png thumbnails from jpg or png images. Hope the code now makes sense Thanks
-
Hi INSERT INTO `itemtable` SET `itemnum1` = $_GET['1'], `itemnum2` = $_GET['2'] , `itemnum3` = $_GET['3'] , `itemnum4` = $_GET['4'], `itemnum5` = $_GET['5'] AND `memberid` = $_SESSION['idnum'] make sure itemnum1, itemnum2, itemnum3, itemnum4, itemnum5 all have default values as 0.
-
Hi I am trying to resize an uploaded image and save it as png. I always get corrupted png thumbnails. Can somebody check the function and tell where i ve gone wrong. function image_thumb($file, $tnfilename) { //maximum width: 225px //maximum height 225px $imageInfo = getimagesize($file); if ($imageInfo["mime"] == 'image/jpeg') $fullImage = imagecreatefromjpeg($file); elseif ($imageInfo["mime"] == 'image/png') $fullImage = imagecreatefrompng($file); $imageWidth = $imageInfo[0]; $imageHeight = $imageInfo[1]; $imageRatio = $imageWidth/$imageHeight; if ($imageRatio < 1) { $newHeight = 225; $newWidth = (225/$imageHeight) * $imageWidth; echo $newWidth;} else { $newWidth = 225; $newHeight = (225/$imageWidth) * $imageHeight;} $tnImage = imagecreatetruecolor($newWidth, $newHeight); imagealphablending($tnImage, true); imagecopyresampled($tnImage, $fullImage, 0, 0, 0, 0, $newWidth, $newHeight, $imageWidth, $imageHeight); imagesavealpha($tnImage, true); imagepng($tnImage, $tnfilename, 70, PNG_ALL_FILTERS); imagedestroy($fullImage); imagedestroy($tnImage); return $tnfilename; }
-
[SOLVED] corrupted download from remote server
werty37 replied to werty37's topic in PHP Coding Help
Hi Barand Thanks a lot. I had \n characters after ?> in one of my includes. Have a nice day Cheers Sujith -
Hi Sometimes webhosting companies disable mail() function by default. You might have to contact your hosting company to enable them... Regards Sujith
-
Hi mike, I am using this in one of my scripts and it seems to work for me. This should work for you hopefully if (!preg_match('/^[\w\d\_\.]{8,15}$/',$var)) { // code } Regards Sujith
-
[SOLVED] corrupted download from remote server
werty37 replied to werty37's topic in PHP Coding Help
Hi everyone, Update: I edited the downloaded binary file (jpg) using vi. And removed the newline characters. Now i am able to view the file. It seems that the addition of \n characters make the downloaded files to be corrupt. I dont understand how the \n characters are added to the file contents. Any pointers would be helpful. Regards Sujith -
Hi You want blah.php to be accessed by say index.php and not by others right.... put the above code in blah.php at the top. Regards Sujith
-
Hi Ken2k7, Add this code to the beginning of the file and others wont be able to access the file directly. Hope this is what you needed Cheers Sujith
-
[SOLVED] corrupted download from remote server
werty37 replied to werty37's topic in PHP Coding Help
Hi toplay, When i upload the file, i copy the filename and mime to database and rename the file with a unique name (d7497f3e-8496-428f-b573-ac9f1a0d7f3d) with no extension. And when i download the file from the remote server. I get the filename and mime type from the database for the corresponding file name (d7497f3e-8496-428f-b573-ac9f1a0d7f3d) Download is working except for the fact that the file is corrupted on download. I tried binary files (jpg, gif) and they all seem to be corrupt as \n characters are added to the beginning of the files. (which i found out by using text files) I hope that would explain the code a bit. The problem is - \n characters are added to the files during download which makes the data to be corrupt! Best Regards Sujith -
Hi Dont know if this would fit your need. Check out http://www.mycontactform.com Try searching if this is not what you wanted Cheers Sujith
-
Hi Try this. if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) exit('You cannot access this file directly'); Cheers Sujith
-
[SOLVED] corrupted download from remote server
werty37 replied to werty37's topic in PHP Coding Help
Hi sorry i missed $... I tried you method. The downloaded file still has the newline.... Any other way? Thanks for your time Sujith -
Hi $imgdata = file_get_contents($_FILES['replacewithfieldname']['tmp_name']); $query = "INSERT INTO users (displayname, displaytype, description, address, address2, city, state, postal, country, website, imagefile) VALUES ('$displayname', '$displaytype', '$description', '$address', '$address2', '$city', '$state', '$postal', '$country', '$website', '$imgdata')"; mysql_query($query) or die (mysql_error()); Sujith
-
Hi, I guess this should do. Use the following in the insert.... file_get_contents($_FILES['uname']['tmp_name']) Cheers Sujith
-
Hi Guys, I am trying to download a file from remote ftp server. When i am trying to download binary data (jpg, gif) it appears to be corrupt. I tried downloading txt files. They seem to have extra space at the top of the file. The upload script is working fine and there is no change in the file contents. When i am uploading i strip off the the extension and assign a unique name to the file. <?php //$filename = from db; //$mime = from db; //$size = from db; url = $GLOBALS['FILESERVER'] . $_SESSION['getfile']; $fp = fopen($url, 'rb'); $contents = stream_get_contents($fp, -1, 0); fclose($fp); header("Content-Transfer-Encoding: binary"); //header("Content-Type: application/force-download; charset=windows-1251"); header("Content-Type: $mime"); header("Content-Length: $size"); header("Content-Disposition: attachment; filename=$filename"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); echo $contents; exit; } ?> I have been stuck with this problem for the past 2 days. Any help will be appreciated. Thanks for your time, Sujith