Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Un-zipping File Problem


Below is a bit of code that opens up and reads a
zip file.

I'm having trouble working out how to read in line
by line. The file I am unzipping is a CSV file and I
need to return each line so I can work on them

$zip = zip_open("$filepath"); // << full path of the file
if ($zip) {
while ($zip_entry = zip_read($zip)) {
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
print "$buf<br>
"; // << what to return each line so i can work
on it
zip_entry_close($zip_entry);
}
echo "<br>
";
}
zip_close($zip);
}




View Complete Forum Thread with Replies

Related Forum Messages:
Recursive File Saving/zipping
it will keep the structure, copy it to a zip file/tar.gz/rar or whatever and email it as an attachment. Say the script is in my server root.

script.php
folder1/
folder1/index.php
folder1/images/
folder1/images/logo.jpg
folder1/images/header.gif
folder2/files/super.zip
folder9/some/etc.txt

script.php would keep the file structure for everything beneath it and compress it and email it. I have been trying to find something like this online, but have been having trouble. this is pretty much just for a backup cron job that.

View Replies !
PHP Exec() And Zipping Upload File In Windows
I have the following code. What I need is to zip the file
(c:webuploadsomeFile) to d:websomeFile.zip.

$cmd = 'c:zipzip.exe '. $movedFile. ' '. $finalFile;
exec( $cmd, $cmd_output );

File is being uploaded by the apache server, but it's not being zipped.
My guess "", escaping, is causing problem in windows path. Do I also
have to escape the $movedFile content? Forexample $movedFile=
"c:webuploadsomeFile".

View Replies !
Zipping
Basically - I want to develop some routines that I can 'read' a file
(ascii / text) that has been zipped up...

I have not found the right command to actually zip up the file in the first place. (automatically via a PHP script)...

Can someone point me to a tutorial / page on actually zipping up files
- into a zip file please...

View Replies !
Dynamic Zipping
I'm working on a downloads site at the moment and need to have a sort of dynamic zipping system, i'll explain:

1. A user visits the site, they are given an individual ID

2. They browse through the files and can click on the 'Add to Download' button if they wish.

3. If they click on the 'Get Download' button, then they are sent to a page, which offers them all the files they selected in a .zip or .tar file for downloading.

View Replies !
Zipping And Raring With Php
How can i zip or rar a file with php?

View Replies !
Zipping Files
I would like to have a form where users select checkboxes that correspond to the files they are interested in receiving. Then have php "package" those files as 1 (i.e. zip or some other compression format) for immediate download.

View Replies !
Zipping All Files In Directory
I need to come up with a script hat will zip all the files in a directory at download. I am working with a virtual host and couldn't tell you if they have any zipping functions compiled with php.

Can i still do this? Also how would i find out if the zipping functions are compiled in php?

I have never done this before and am drawing a blank on what i should be looking for or at.

Thanks guys

View Replies !
Download A Directory Without Zipping
I have groupings of files in different folders. The users have the option of downloading each file individually or the entire folder that that file is in.

is there a way for me to allow the user to download the entire folder without me having to zip the folder? Like sometimes on torrent you can download something and it shows up in a folder unzipped. Any ideas?

View Replies !
Zipping External Files
I was wondering if its possible to build a zip for external files, specifically images. I havnt used PHP's zip features before and if it can't do what I want it to, I don't wanna spend time learning how to use it so im wondering if theres anybody that knows the answer to this question or someone who is experienced and is willing to try it out for me /

View Replies !
Zipping Up A Folder And Its Contents?
I installed the zip extension for PHP 5.2, but reading the documentation, I can't figure out how to zip up an existing folder.  I mean, I have this folder with a bunch of files in it, right?  I *could* scan the whole thing and add each file to a newly created zip archive, but I don't want to.

Is there any way to tell PHP to zip up a folder and have its contents be everything inside that folder?

View Replies !
Zipping Multiple Files
i am working on a php page, process_extract_papers.php, that helps to zip documents for me. One problem i faced was that when the documents are more than 20mb, the system will fail and thats because it exceeds the temp directory memory. And instead of zipping one big file, i want to zip multiple files instead. Firstly, it will be much easier to download. The problem is that i managed to zip the first file and able to download it. So get the next part of the file, i will need to press a button called Extract Next. However, even though i did that, when i press start download button, i will still be downloading the first file.

View Replies !
Zipping Multiple Files Using Gzencode
I'm successfully using gzencode to zip a file using the following code ala the documentation: PHP Code:

View Replies !
Active, Online Zipping Or Rar'ing.
i want to upload something through a form, and have the script do some sort of compression file, like:

.zip
.rar
.tar.gz

etc...

if it makes any difference, it is a unix machine.

View Replies !
PHP Class/library Zipping Client Computer Files And Upload To Server
Can anyone suggest good PHP class/library that can zip client local
files and upload to the server? Single package is great as well as
separate packages.

View Replies !
Use Download Manager If File Link: File.php?file=something.zip
I have a piece of code:

<?php
    $path = "/home/surfall/secret";
    $mainpath = "$path$file";
    header("Cache-Control: ");# leave blank to avoid IE errors
    header("Pragma: ");# leave blank to avoid IE errors
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename="".$file.""");
    header("Content-length:".(string)(filesize($mainpath)));
    sleep(1);
    readfile("$mainpath");
?>


However I can't seem to get download manager to work with it? So that I can download the file in pieces, thus the download will be faster. (I use Flashget as the download manager)

View Replies !
To Get A File Name, File Size, File Type...?
Is there a way to get information about a file BEFORE it is submitted to the server?
I am trying to make a upload progress bar from scratch WITHOUT THE PRON.C PHP FIX!!!
I found the file being uploaded in my NET://WINN01910//TEMP folder and I can outputs its file size in a popup with a one second refrehs, but this makes it so the USER needs to know the full file size to know if its anywehre near done. 

Is there a way to get the filesize from the clients side?  Possibly javascript that uses ajax to submit the values to the server before the file is sent but when it is selected?? Is there an easier way to do this and/or do you have any ajax example code of how it might work?

I also have another problem, Althoguh i can echo the filesize of what is recieved so far, I am just glob()ing the temp folder for: "php*.tmp" but is there a way to tell the tmp file so they don't see everyone's uploads?

View Replies !
How To - File Download Link File.php?file=something.zip
I'm trying to get/make a code that will make it possible to download from urls like "file.php?file=something.zip"

I've made one, but the problem is that I can't seem to get download manager working with it, and this is a big problem.

As you all probably know, with the download manager I can download the file in pieces and pause, start the download process. I use "Flashget" as my download manager. But if someone else knows one that would work with the url, let me know! Code:

View Replies !
File Download Problem - Change A Binary File Into A Text And Open It In A Browser
I have uploaded files to mysql (doc and xls) using the tutorial. The problem comes when I try to download. Again I followed instructions in the tutorial. When I click on the link to download the file, it formats it as text and sends it to the browser instead of seeing it as binary and offering me a download box. PHP Code:

<?
if(isset($_GET['id']))
{
    include 'includes/configdb.php'
    include 'includes/opendb.php'

    $id      = $_GET['id'];
    $query   = "SELECT name, type, size, content FROM upload WHERE id = '$id'";
    $result  = mysql_query($query) or die('Error, query failed');
    list($name, $type, $size, $content) = mysql_fetch_array($result);

    header("Content-Disposition: attachment; filename=$name");
    header("Content-length: $size"); ....

View Replies !
FIle Uploads: Empty _POST And _FILES Arrays When File Too Large
Uploading of files.. AFAIU from the manual, if a file is larger than the
size defined in the form or larger than upload_max_filesize in php.ini,
that _FILES['file']['error'] should hold an INT error code.

The file upload system is working fine if the file is smaller than the
defined size, but if it's larger, then both the _POST and _FILES arrays
are completely empty:

array(0) {
}

I can obviously check to see if $_FILES is set and contains elements,
but I was hoping for more specific error handling (reason as to why the
upload failed).

Has anyone else encountered this? Any info welcomed =)

View Replies !
Pdf File Download - There Was An Error Opening This Document. The File Is Damaged And Could Not Be Repaired
I have a small script that does a 'force download' of a pdf file - the problem is while it downloads the correct file, when I attempt to open the file once download it is corrupted - I get the following error in Adobe Acrobat:

"There was an error opening this document. The file is damaged and could not be repaired." Code:

View Replies !
Checking File Existence Through A List Of File Locations Gathered From An Array
I've been trying to wrote a code to check the existence of some files gathered from a field in mySql database.

And I am kind a stuck at a point where I get the file locations from the database but when it passes those locations to file exist it keeps telling me the file does not exist.

Only first file exists the other 2 file does not exist to test if the code was working or not. Code:

View Replies !
Check The File Mimetype To Validate If The Uploaded File Is In The Correct Format
I used PHP to upload some flash files. Here, I want to check the file mimetype to validate if the uploaded file is in the correct format. But, when I am uploading .flv (flash video file), PHP returns the mime-type as "application/octet-stream". :confused::confused:

According to my research, flv should return video/x-flv. Please anyone help me to get it working correctly?

View Replies !
File Upload - Nothing In The $_FILES Array After Selecting A File And Clicking Submit
I have to following HTML form to upload a file:

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
<input name="userfile[]" type="file" />
<input type="submit" value="Submit" />
</form>

In my upload script I have:

if(is_uploaded_file($_FILES['userfile']['tmp_name']))
{
..do some code, etc.
}

There seems to be nothing in the $_FILES array after selecting a file and clicking submit. Any ideas why? All I get is this when trying to echo some of the $_FILES variables: File Array is Array bytes, i.e. the word Array is just being printed instead of the relevant info.

View Replies !
Upload A File And Have  Alink Of The File Displayed On The Webpage.
I want to upload a file and have  alink of the file displayed on the webpage.

q)Now I can do an image but is there anything else i need to know? eg fileupload and store on a dir and have a link to the file in  mysql. The file would be .txt ot .doc etc

q)Is there a way to upload  a lot of text eg 2000 words to a webpage and have the content displayed on a webpage ?

View Replies !
File Upload Fails - Different Files And Sizes And The Time Required Seems To Be Proportional To File Size,
I'm using IE5.5 as client and php4 on linux/apache as server. I've followed the examples for doing a file upload from a form and everything appears to work from the client side. In my script I see the following values:

UploadedFile=none
UploadedFile_name=test.html
UploadedFile_type=text/html
UploadedFile_size=0

I've tried different files and sizes and the time required seems to be proportional to file size, so I think there is a file being sent by the browser. The UploadedFile_name and type reflect the file being sent. Since I'm not getting a name for the temporary file in UploadedFile (if it was in fact created) and size = 0, I can't move or copy it. Code:

View Replies !
Email With File Attachements - How To Upload File To Server From Browser?
I have a PHP script that sends an email with attachment and works great when
provided the path to the file to send.

However this file needs to be on the same server as the script.

I want to develop a webpage where people can send attachments that are
stored on their local PC.

I know I can use the <input type="file" > HTML to generate a file box that
allows the user to navigate to a file on their PC and product a file path,
but how do I then upload this file onto file server to email out with my PHP
email script?

Is there an easy way to do this?

Or can I approach this problem from a completely different angle.

View Replies !
Creating Link To File Or Temp File For User Download
I am designing a document management system (DMS). The files are stored
in a directory on the webserver. The filenames for the documents are
stored in a MySQL database. The DMS will track revisions from the
initial version through the updates. We must have strict permissions
set so only authorized personnel can access some documents. All of the
documents when uploaded are given totally random names such as
"114723fb5422c6bd5ed18f6.doc". Is there a way, without the webserver
creating a new file name "document_specs_ver2.doc" to have the file
download named "document_specs_ver2.doc".

If I must physically create a new file, how do I know when the
webserver would be allowed to delete it? Notes: The files will be in
several different file formats, not just "doc".

View Replies !
Header Function, File Download, Temp File Disappears
I have the following headers:

if (preg_match("/compatible; MSIE/i", "$browser_type")){
header("Content-Tranfer-Encoding: binary");
header("Content-type: ".$assoc["type"]."");
header("Content-Disposition: attachment; filename="".$assoc["name"].""");}
echo $assoc["file"];

which starts the download of an mp3 file in one particular case. If you do not save target as and just select 'open' the temp file is zero bytes even though the download process took a while and showd how much progress you were making. So something is happening to the temp file.

View Replies !
Warning: File(): URL File-access Is Disabled In The Server Configuration
Does any one know how to work around this error on a web site?

Warning: file(): URL file-access is disabled in the server configuration ...

View Replies !
Load .txt File From Computer And Save The File In Www/folder Director
anyone know how to add the .txt file from computer into the localhost www/Myfolder directory.

View Replies !
Download File And Delete File From Server With One Button Click
I want the user to be able to download a CSV file and delete the file from the server all with the click of a button.  Currently, in firefox, it will just display the CSV and not delete it. In IE, it will download the CSV and not delete it. Code:

View Replies !
Pass The Source File Name To The Destination File In An Ftp_put Operation
I would like to pass the source file name to the destination file in an ftp_put operation, but for the life of me, cannot figure out how to do this. I have an input form and php script which work fine, but the destination file is always named sample.wav....

View Replies !
Warning: Move_uploaded_file() Unable To Move *file* To *new File* In *script*
I'm having trouble with move_uploaded_file()- my script was working fine until a month or two ago when it suddenly stopped. Now I get the error:

Warning: move_uploaded_file() Unable to move *file* to *new file* in *script*

Thats it, no permissions error or "unable to open stream"- all the searching I've done everyone seeems to get another error- but I'm only getting the one. Permissions on the folder are 777, the paths are absolute and definitely correct, safe_mode and open_basedir are both off. I even called is_uploaded_file() on the line before it and it returned true. The only thing I can think of is that the hosts upgraded to php4.4 recently- could that be it? Are there any known problems (or changes that would break my script)?

View Replies !
Uploading A File And Checking Form Fields, Without Reselecting File?
I've got a page upload1.php which contains a form that asks the user to select a couple of variables:

File owner (compulsory)
Menu ID (compulsory)
File Description (optional)
File to upload

This form then goes to upload2.php where I check the form values, and if all ok write the info to my database and upload the file.

File owner and MenuID are compulsory, the first thing upload2.php does is check that these are completed. If either field is missing, the form is presented again for the user to complete the missing fields. Fields that were completed are carried forward into this form so the user doesn't have to re-enter.

the question: While I can carry the other fields forward from upload1.php to upload2.php, I can't figure out how or if I can carry forward the location of the file to be uploaded so the user doesnt' have to reselect?

Form from upload2.php follows. Area in question is highlighted - it's my best guess, but it doesn't work.....

View Replies !
Implode - Read The Contents Of A File (servers) And Create A New File
I am trying to read the contents of a file (servers) and create a new file off of it with more information line by line. You will see the logic soon. I know how to do this via a script but not php.

The end result is servers2 should have (ssh root@$count 'echo $user|passwd --stdin root' ; done). The variable $count is the list of servers in the (servers) file, so it will have the line above for each server name. Code:

View Replies !
Download Script That Stores That File Name And The File Path In The Database
I wrote a download script that stores that file name and the file path in the database and then when someone clicks the link that goes to http://www.domain.com/index.php?download=file.zip the script checks for a file names file.zip in the database. Code:

View Replies !
After Fwrite To A File Can The New File Be Loaded In Curr. Browser Window?
Assuming that I successfully use fopen("$filetoget", "wb"); to open a file, then write stuff out to the file using fwrite($outputfile, $data); and close the new file using fclose($outputfile);

Is it possible for the current PHP script to load the new file (or another webpage, etc) over the top of itself into the browser window in which the PHP script is currently running?

And assuming that there is a way to load the new file into the window, can it be opened in such a way that any embedded php code in the output is executed as th enew page is loaded?

View Replies !
Open File, Put First 5 Lines Into A Variable, Close File...
1) I want to open a file on my server.
2) I want to read only the first 5 lines.
3) Put the first five lines into a variable.
4) Close the file.
5) Display the contents of the variable.

I know how to use the fopen() but I have big problems just trying to read the first 5 lines only? I tried many things. I downloaded some search scripts which displayed the <meta> tag only from html pages...

What is this guy doing?

Well I have a big site and content is added and changed everyday. I have a dynamic page that reads a directory for files and then puts a link (well it includes the file for reading on my php page). That works great! MY PROBLEM is that I want not only a link but a small description below it (basically the first five lines on the file)...

See so far:
Quote: if (isset ($content)) {
include ("files/$content.html");
echo "<p><A HREF="read.php"><b>Back to index</b></A>";
} else {
echo "<b>Opening directory, reading files, and listing them as a link</b><p>";
$handle = opendir('./files');
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo eregi_replace (".html", "", "<A HREF="read.php?content=$file">$file</a><p>");
}
}
closedir($handle);
}

View Replies !
File Transfer :: Move_uploaded File Not Working On New Server
I've worked with PHP for a few months and have had several problems, but that's the learning process. I developped a site for the company I work for which involves extensive database manipulation and image integration. The file upload script worked fine before, but now it won't work. My hosting company must have changed something, but now when I upload a file, it uploads but I can't move it. It crashes when I run the 'move_uploaded_file' function and runs the error script. PHP Code:

View Replies !
File Upload Warning: Max File Size Exceeded
I have 2 files, one is a HTML file with the code to create a Browae and Submit Button for uploading a file. (This works fine). BUT, when I click the submit button, I want the file to upload to a directory on my C:/ drive which I have indiciated in the PHTML file, but I keep getting the following error and I don't know why.

Warning: Unable to open 'php2' for reading: Unknown error in C:apachehtdocs/submitassprac.phtml on line 5 Couldn't copy the file! OR

Warning: Max file size exceeded - file [img1] not saved in C:apachehtdocs/submitassprac.phtml on line 0 Code:

View Replies !
Open .php File With PHP Designer 2007 By Clicking The File In XP
In windows XP, I want to be able to click on a .php file and have it
opened in PHP Designer 2007,
Or right-click on it and have an "edit" menu option presented to me.
I know how to tweak the registry to do this in general, but what would
the command line look like in this specific case ?
PHP Designer does not do this automatically. It is as if the program
does not allow commandline options.
It only opens with the last file used or a menu of recently opened
files.

View Replies !
PHP File Handling Open A Simple Text File
I am trying to open a simple text file using php, read the content in , close the file and display the content to a page. I can't seem to get this code to work. When i run the page i get no errors but and the "this doesn't work" string at the bottom prints out ok. I have tried putting the 'PHPdata.txt' section in as a url ie 'http://localhost/phpdata.txt' but this doesn't seem to work either.

I am using windows xp and apache. I am trying to firstly get this code to work with the aim of opening and pulling back the html content from a remote page to mess around with on my server. Code:

View Replies !
File Upload :: Warning: Fopen - No Such File Or Directory
I’m getting the following errors when I try to run the script below on a live server. It’s a crude script which uploads text and images directly into MySQL. It works fine on my local machine, I have Apache, PHP4 and MySQL running on windows. The live server is Unix.

When I try to upload images from my loacal pc I get the error below, when I placed an image file within the same directory as the script on the live server and tried to upload it that worked. I wanted the script to allow image uplload from a client pc Can anyone offer a suggestion?

Warning: fopen("C:Apachehtdocs Grey.jpg", "r") - No such file or directory in /usr/local/home/httpd/vhtdocs/sitehostin/moondance/backend/test_imagedb.php on line 57
Code:

View Replies !
Remove A Single Element Out Of That File Without Deleting The Whole File?
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?

View Replies !
PHP File Upload Unexpected Error - File Too Large?
I have a short basic script to upload files. It works fine with small files,
but with longer files it gets stuck.

Here's the fragment, the input file is loaded in "$file" from an HTML form
as usual.

....
$img_str = fread(fopen($file, "r"), filesize($file));
$data = addslashes($img_str);
// --------------------- up to here the execution is correct and fast (<1
second)

$sql="INSERT INTO $table (".
" file_name,".
" file_type,".
" file_size,".
" bin_data)".
" VALUES (".
" '$file_name',".
" '$file_type',".
" '$file_size',".
" '$data')";
// --------------------- it gets stuck
here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mysql_query($sql) or die ("SQL error ..$sql");

I have already set the php.ini variables as follows:
memory_limit = 16M
upload_max_filesize = 6M

I also checked the execution time to max_execution_time = 300 (even though I
don't believe it should be necessary).
The server is a P4 1.8 GHz, 256MB RAM

View Replies !
Displaying File Path In File Input Field
i have file input field in a form like this:
<input name="isbn" type="text" size="25" value="<?php echo
$_POST['isbn'] ?>" />
<input name="image" type="file" size="25" value="<?php echo
$_FILES['image']['name'] ?>" />

when i press "submit" button, the same page gets loaded... if my
$_POST['isbn'] is empty, i want to have the file path on "file input
field" to redisplay on that same field... it's possible in text input
field but i don't know of a way to do it in file input fields...

View Replies !
PHP/IIS: File Read/Write OK, File Unlink Denied
I've got PHP running fine on IIS (OS: Server 2003, SP1; IIS: 6.0; PHP:
4.3.11).

In PHP, the user uploads a file, which is then processed and the
contents are inserted into a new file, created in PHP, onto the server.

This bit works fine, the new file created by PHP is correctly stored.

Later, once the user confirms the upload and PHP inserts the contents
of the file into the DB, the code tries to remove the file created in
PHP moments earlier, via the unlink() function.

What I see on screen is the following: Permission denied

I have made sure that the permissions for the Internet account that
created (and is trying to delete) the file have full permissions over
this particular folder and the files within it. But the user must have
permission anyway, because they are able to create this file in the
first place.

I've looked at the permissions for the file in PHP, which read: 0666.
So everthing *appears* ok to me; I can't see where the permission issue
is coming from.

View Replies !
Mkdir() How Do I Automatically Make A Index File And A Css File
using mkdir() how do i automatically make a index file and a css file. what i really mean is once the directory has been made how do i make it so i have a index and css file there, its just because im making a forum hosting service and i need all the files automatically set up in the directory. how can i do this?

View Replies !
Include Header.php File Into Main Index.php File
I am trying to include my header.php file into my main index.php file. Every thing works except that I can't get an image to appear. Code:

View Replies !
How Can I Find Out Parent (including) File Of Included File?
How can i find out parent (including) file of included file?
Lets imagine that we want to for example auto_prepend file to each file on our server that would write out the name of file  its being executed. I know, i can use PHP_SELF but what if i want to write name of file which is already included?

I have a web page and i want on it show its name even if it was included, but not the included page itself is showing name but auto_prepend file to each php file, its duty of this auto_prepend_file to write it out i dont want myself to echo it on each page? do you feel me?

View Replies !
Exporting DB Results (or Flat File) To An Excel File
I have two scripts, neither of which have been written, that will need to collect user information. They will either write to a flat file or to a MySQL DB, and I need a way for an administrator to grab an Excel file based on this data.

First, no more than 100 people are expected to sign up, so flat file is certainly viable. Do you recommend I use DB or flat file?

Second, based on your recommendation, how should I go about exporting the user data to an Excel file? There will be about ten form fields per registration to give you an idea.

View Replies !
Php File To Call On A File In A Password Protected Directory
Does anyone know is I can have php file calling on a file in a password protected directory (through basic authentication)?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved