Re: File Upload From Web Page to Replace Data
| From: | David Robley | Date: | Thu, 15 Jun 2000 01:47:24 +0000 |
| Subject: | Re: File Upload From Web Page to Replace Data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1899@lists.php.net to get a copy of this message | ||
On 14 Jun, Don Smith wrote:
> I started out knowing nothing about PHP or MySQL a month ago, but I've
> cobbled together a site that's almost finished at:
>
> http://www.dallasbureau.com
>
> With my admin pages at:
>
> http://www.dallasbureau.com/admin.html
>
> The site is for testing, so if you look, feel free to try the logins and
> passwords, and the login and password for the admin area is admin/hardies.
> On the main site, the data listed is different depending on who logged in,
> with a calendar to show available delievery dates.
>
> While I've got a few kinks yet to iron out, the one thing that I've run
> against the wall about is the uploading of new database information.
>
> In my case, I need to have the user upload a tab-delimited text file with
> information to REPLACE the data in my products table.
>
> On one page, I've put the following code to have the user browse to his file
> and send it:
>
> <FORM ENCTYPE="multipart/form-data" ACTION="ul2.php" METHOD=POST>
> <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="100000">
> Send this file: <INPUT NAME="userfile" TYPE="file">
> <INPUT TYPE="submit" VALUE="Send File">
> </FORM>
>
> Then, on the ul2.php page, I've put some code to handle it, but clearly its
> very wrong. The code above is borrowed and I've never heard of $file_type
> and $file_size for one, but even when I comment-out those lines below, my
> script still falls apart.
You are probably looking for the functions filetype() and filesize().
But filetype() won't return a value 'txt'; you'd need to check the file
extension to see if it were .txt - not that that _means_ anything, of
course ;-)
Oh, and most importantly, the page that does the uploading MUST
move/copy the uploaded file from it's temp location, as PHP will delete
the temporary uploaded file at the end of the uploading script.
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA