Jump to content

venkir

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

venkir's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. filesize will give you the size of the file and not the value of the count stored int the file. Looks like you want to open the file, read the value stored in the file and then add to it, store it back. If so: you will have to use fread and store the value in a variable and not use fliesize. Hope that helps!!! -V
  2. Hi: In my php I am creating two files, both contain the output desired in different format, one in xml and one as plain csv. Let us say they are called abc.xml and abc.csv. These two files are created in a 'uploads' dir in the web server. I would next like to include these two files into a new ZIP archive called 'output.zip' or 'output'gz' (don't care). I read all about the zlib functions, but to me ot looks like when you open the file for writing you can use either fopne or gzopen. My problem is if I use gzopen I will still end up with two files (although they will now be zipped) and I cannot download two files using the 'force donwload' method. My ultimate aim is when the user clicks 'Save files' the force download method will download the 'output.gz' file, provides capability to the user to save it wherever they want in the local file system. Once they have save and they unzip this file they can extract abc.xml and abc.csv. How do I do this? Thanks for your time in advance. -Venki
  3. Thanks, Worked beautifully, wonder why the PHP Cookbook did not have any examples of this neither did the PHP and MySQL web development book. Anyway that justifies the existance of this forum. I have two additonal questions: To explain better, the current process is: 1. getfile.php: Gets the original input file by using a form and a submit button, calls processfile.php 2. File gets uploaded to web server successfully, invokes processfile.php which --moves the uploaded file, --process each record --Forms a table to display results in html --and creates two ouput files in the web server one with .xml and one with .csv extension 3. I put the force download snippet of code before the html display in this php. But I don't see the results on the screen. When I click on the 'Submit' button in the getfile.php, it waits (processing ...) and then the pop-up window to save the first xml file comes up. File is saved successfully, but ....... 1. The second csv file is not downloaded. 2. The html display does not show up now. Why and how to fix it? Thanks again for all the wonderful people out there.....This is one site that I am definitely going to contribute to. -Venki
  4. Hi All: This appears to be simple but I am stumped. I have searched through all the past post but to no avail. Basically: 1. User clicks on a link and a php page is presented. 2. User selects a local TEXT CSV file and clicks on the 'Upload File' button. 3. Local file is sent to the web browser, where each line in the CSV file is read, processed, geocoded. 4. A HTML table is formed to display the results of the geo coding. Everything works until this step. 5. The user needs to now click on a button, type in the name for the output file (just the name ....) and the code should use the old directory path, append the output file name (as entered above), append the extension ".csv", open the file, write to it and close the file. I know all about fopen, fwrite and fclose. My specific questions are: 1. How do I parse and retain the directory path of the original csv file so that I can save back to the same dir? $_FILES['userfile']['name'] does not have the dir path. 2. In the php file which displays the result, how do I create another button that will enabe the user to traverse the local file system pick another location and type in the file name for the output? 3. Lastly, since the results are displayed in the browser, the data has already been sent to the browser. If I save the results in an array in the php that processes the input, after the user clicks on this button, is the array available to me to then traverse and fwrite to the file? I guess fundamnetally I don't understand where the data resides since I don;t want it to go back to the web server just to save the ouput to a local file. Any help will be much appreciated!!!! -Venki
  5. I think you are looking for a way to browse the local file system. One way I have done it in the past is something like this: "<form action=\"saveoutput.php\" method=\"post\" enctype=\"multipart/form-data\">     <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"5000000\">     <table border=\"0\">     <tr>     <td><b>Please select directory and file name for output:</b></td>     <td><input type=\"file\" name=\"savefile\"></td>        </tr>     <tr></tr>     <tr><td><input type=\"submit\" value=\"Save Output to kml format\"></td></tr>     </table> </form>"; The <input type="file" ...> wil create a button with the prompt 'Browse..' and that will let you browse the file system and pick a file. Hope that helps!! -Venki
  6. I fixed my own problem. I hardcoded the entire path instead of using the relative path for the destination filename and for some reason  it worked. All documentaion says that it is relative to where the php script executes. Anyway that was my fix if it helps anybody. -Venki
  7. Hi all Gurus: I have not been able to make file upload work for about 2 days now and am at the end of my wits -----------Code Snippet ---------------------- <?php   require ('page.inc');     // Check for error   $userfile_error = $_FILES['userfile']['error'];   if ( $userfile_error > 0)   {   $pagecontent =  $pagecontent . 'Problem :';   switch ($userfile_error)     {       case 1:  $pagecontent =  $pagecontent . 'File exceeded upload_max_filesize';  break;       case 2:  $pagecontent =  $pagecontent . 'File exceeded max_file_size';  break;       case 3:  $pagecontent =  $pagecontent . 'File only partially uploaded';  break;       case 4:  $pagecontent =  $pagecontent . 'No file uploaded';  break;     }     exit;   }     // Extract Form fields   $userfile = $_FILES['userfile']['name'];   // Check the input values    if ( empty($userfile))   {   echo 'One of the required fields was empty, please check and try again';   }   else   {   // Put the file where we want it   $upfile = '/uploads/' . $userfile;      $tmpfile = 'c:\\wamp\\tmp\\' . basename($_FILES['userfile']['tmp_name']);   echo $tmpfile . " <--- used basename and appended to the path <br>";   echo $_FILES['userfile']['tmp_name'] . "<--- Original tmp file<br>";   echo $_FILES['userfile']['name'] . " <--- FILES name var <br>";   echo $_FILES['userfile']['size'] . " <--- FILES size var<br>";   $pagecontent = $pagecontent . $_FILES['userfile']['type'] . " <--- FILES type var<br>";     if (is_uploaded_file($_FILES['userfile']['tmp_name']))   {   if(!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile))   {   echo 'Error: Could not move file to destination directory.';   }   else   {   echo "<h2>Processing File:" . $upfile. "</h2>\n<br>";   }   }   else   {   echo 'Error: Possible file upload attack :'. $_FILES;   } ?> -----------End Code Snippet ---------------------- and the results in the browser are c:\wamp\tmp\php4B.tmp <--- used basename and appended to the path c:/wamp/uploads\php4B.tmp<--- Original tmp file angus_input.csv <--- FILES name var 1906 <--- FILES size var text/plain <--- FILES type var Error: Could not move file to destination directory. with addtional warnings Warning: move_uploaded_file(/uploads/angus_input.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\GeoCoding\geocodecsv.php on line 49 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'c:/wamp/uploads\php4B.tmp' to '/uploads/angus_input.csv' in C:\wamp\www\GeoCoding\geocodecsv.php on line 49 Clearly the problem is the tmp upload file full path name which is 'c:/wamp/uploads\php4B.tmp'  (NOTICE the different slash direction) How do I fix this? I tried stripslashes, tried re-constructing the tmp file and then providing it to function move_uploaded_file, but it still does not move it Can anyone help? Thanks a lot in advance -Venki
×
×
  • 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.