Jump to content

nandakishor

New Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

nandakishor's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am sorry, If I am asking a basic question.. I am working for a project where I need to give a upload and submit option for client. In that client will browse the local path and selects required "EXCEL" file and if they click to submit, then the content should be displayed in the webpage.. these are few codes I went through, but I thought I am not in the right way.. <HTML> <HEAD> <TITLE> PHP File Upload Script </TITLE> </HEAD> <BODY> <?php if( isset($_POST['submit1'])) { // $_FILES is the array auto filled when you upload a file and submit a form. $userfile_name = $_FILES['file1']['name']; // file name $userfile_tmp = $_FILES['file1']['tmp_name']; // actual location $userfile_size = $_FILES['file1']['size']; // file size $userfile_type = $_FILES['file1']['type']; // mime type of file sent by browser. PHP doesn't check it. $userfile_error = $_FILES['file1']['error']; // any error!. get from here // Content uploading. $file_data = ''; if ( !empty($userfile_tmp)) { // We encode the data just to make it more database friendly $file_data = base64_encode(@fread(fopen($userfile_tmp, 'r'), filesize($userfile_tmp))); } switch (true) { // Check error if any case ($userfile_error == UPLOAD_ERR_NO_FILE): case empty($file_data): echo 'You must select a document to upload before you can save this page.'; exit; break; case ($userfile_error == UPLOAD_ERR_INI_SIZE): case ($userfile_error == UPLOAD_ERR_FORM_SIZE): echo 'The document you have attempted to upload is too large.'; break; case ($userfile_error == UPLOAD_ERR_PARTIAL): echo 'An error occured while trying to recieve the file. Please try again.'; break; } if( !empty($userfile_tmp)) { // only MS office and text file is accepted. if( !(($userfile_type=="application/msword") || ($userfile_type=="text/plain") || ($userfile_type=="application/vnd.ms-excel")) ) {echo 'Your File Type is:'. $userfile_type; echo '<br>File type must be text(.txt) or msword(.doc).'; exit; } } echo filesize($userfile_tmp); } echo ?> <form name="profile" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>" target="_self" enctype="multipart/form-data" > <P align ="center"><input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <input type="file" name="file1" value="AttachFile" device="files" accept="text/*" tabindex=18 > <input type="submit" name="submit1" value="Submit" /> </P> </form> </BODY> </HTML> from the above code I am getting only file size.. This code will displays the content of excel file but it is a hard coded one, but I need client should select that file and content get displayed in the webpage itself... <?php error_reporting(E_ALL ^ E_NOTICE); require_once 'excel_reader2.php'; $data = new Spreadsheet_Excel_Reader("test.xls"); php echo $data->dump(true,true); ?> Thanks in advance...
  2. @ChristianF, Actually, I am very new to PHP and also for software sector, so I didn't aware about validating the MIME-types. Thank u very much for showing me a right path. Any doc is there to study about this. I will try it out. Any thing I have to work out other than validating.
  3. For other than jpeg, just we need to change the Content-type image/png, image/gif.
  4. I got this code and it is working fine... $conn = pg_connect("user = postgres password = nkr@123 host = localhost dbname = ARKREJ"); $res = pg_query($conn, "SELECT photo FROM public.zdata_4326, public.zdata WHERE zdata_4326.gid = zdata.gid AND zdata.gid = 1;"); $raw = pg_fetch_result($res, 'photo'); header('Content-type: image/jpeg'); echo pg_unescape_bytea($raw); Any further suggestions....Please
  5. I am not getting any error report....I got only a blank page... If I run this code... //header("Content-type: text/xml"); $conn = pg_connect("user=postgres password=nkr@123 host=localhost dbname=ARKREJ"); if (!$conn) { echo "An error occured.\n"; exit; } $result = pg_query($conn, "SELECT photo FROM public.zdata_4326, public.zdata WHERE zdata_4326.gid = zdata.gid AND zdata.gid = 1;"); if (!$result) { echo "An error occured.\n"; exit; } $xml_result="<resultxml>"; $num = pg_num_fields($result); while($row = pg_fetch_array($result)){ $xml_result.="<record>"; for ($i=0; $i < $num; $i++) { $xml_result .= "<".pg_field_name($result, $i).">".$row[$i]."</".pg_field_name($result, $i).">"; } $xml_result.="</record>"; } $xml_result.="</resultxml>"; echo $xml_result; I got this message, What to do, I am not understanding....
  6. I have Images in bytea form in PostgreSQL/PostGIS database, i want to display them in a webpage using PHP - PostgreSQL. I got lot of examples and I worked out but not getting output from them... Few codes I have used. $conn = pg_connect("user = postgres password = nkr@123 host = localhost dbname = ARKREJ"); $res = pg_query($conn, "SELECT photo FROM public.zdata_4326, public.zdata WHERE zdata_4326.gid = zdata.gid AND zdata.gid = 1;"); if (!$res) { echo "An error occured at result.\n"; exit; } if($res) { $Row = pg_fetch_row($res, '0'); $Object = pg_locreate($conn); header("Content-Type: image/jpg"); $File = pg_loopen($conn, $Object, "r"); pg_loreadall($File); } else {echo "The query failed!?! There is no row with id=1!";} Another one display.php $conn = pg_connect("user = postgres password = nkr@123 host = localhost dbname = ARKREJ"); if (!$conn) { echo "An error occured.\n"; exit; } $temp = "C:/Program Files/OSGeo/MapGuide/Web/Apache2/htdocs/tmp.jpg"; if (!$temp) { echo "An error occured at temp.\n"; exit; } $result = pg_query($conn, "SELECT (photo, '$temp') FROM public.zdata_4326, public.zdata WHERE zdata_4326.gid = zdata.gid AND zdata.gid = 1;"); if (!$result) { echo "An error occured at result.\n"; exit; } if ($result) { While ($line = pg_fetch_array($result)) { $ctobj = $line["photo"]; echo "<IMG SRC = show.php> </br>"; } } else {echo "File does not exists"; } show.php header("Content-type: image/jpeg"); $jpeg = fopen("C:/Program Files/OSGeo/MapGuide/Web/Apache2/htdocs/tmp.jpg", "r"); $photo = fread($jpeg, filesize("C:/Program Files/OSGeo/MapGuide/Web/Apache2/htdocs/tmp.jpg")); echo pg_unescape_bytea($photo); Can anyone please help me from this... Thanks in advance..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.