quick simple upload

This is a discussion on quick simple upload within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi, I would like to upload a 15Mo zip file on my site. Is there a quick script (no-password, ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-14-2004
Québec
 
Posts: n/a
Default quick simple upload

Hi,

I would like to upload a 15Mo zip file on my site. Is there a quick script
(no-password, etc necessairy) to do this. This is a one time usage only.
The precise number of bytes will be know only by the php.ini file.

Thank you in advance

Jean

--
http://jeanpierredaviau.com



Reply With Quote
  #2 (permalink)  
Old 12-14-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: quick simple upload

Québec wrote:
> I would like to upload a 15Mo zip file on my site. Is there a quick
> script (no-password, etc necessairy) to do this. This is a one time
> usage only. The precise number of bytes will be know only by the
> php.ini file.
>


Why don't you use ftp if it's for one-time use only?

JW



Reply With Quote
  #3 (permalink)  
Old 12-14-2004
Québec
 
Posts: n/a
Default Re: quick simple upload

Because it is for an input from the web, from a user who would have to
painfully have to learn how to use and install ftp.

Jean
"Janwillem Borleffs" <jw@jwscripts.com> a écrit dans le message de
news:41beff41$0$8906$abc4f4c3@news.euronet.nl...
> Québec wrote:
> > I would like to upload a 15Mo zip file on my site. Is there a quick
> > script (no-password, etc necessairy) to do this. This is a one time
> > usage only. The precise number of bytes will be know only by the
> > php.ini file.
> >

>
> Why don't you use ftp if it's for one-time use only?
>
> JW
>
>
>



Reply With Quote
  #4 (permalink)  
Old 12-14-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: quick simple upload

Québec wrote:
> Because it is for an input from the web, from a user who would have to
> painfully have to learn how to use and install ftp.
>


Here's a quicky:

<?php

// Name of the dir with 777 permission, to move the
// uploaded file to, without a trailing slash
$dir = "temp";

if (isset($_FILES['file']) && !$_FILES['file']['error']) {
list($name,,$tmp_name) = array_values($_FILES['file']);
move_uploaded_file($tmp_name, "$dir/$name");
}

?>
<html>
<head>
<title> New Document </title>
</head>

<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" />
</form>
</body>
</html>


JW



Reply With Quote
  #5 (permalink)  
Old 12-14-2004
Québec
 
Posts: n/a
Default Re: quick simple upload

With my first trial:
This server dont accept 'post' so I replaced with get
Where do I set it to POST?Php.ini? Config.inc
---------------
in php .ini

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
upload_tmp_dir = "secret\EasyPHP1-7\tmp\"

; Maximum allowed size for uploaded files.
upload_max_filesize = 15M

---------------------------
I replaced
<?php



//FULL PATH
$dir = "secret/EasyPHP1-7\www\~uploads\";

if (isset($_FILES['file']) && !$_FILES['file']['error']) {
list($name,,$tmp_name) = array_values($_FILES['file']);
move_uploaded_file($tmp_name, "$dir/$name");
}

?>
<html>
<head>
<title> New Document </title>
</head>

<body>
<form method="get" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" />
</form>
</body>
</html>



http://localhost/mydir/~upload/uploa...%5Caupload.zip

no errors is displayed the page comes back as it was

nothing is uploaded

Jean


Reply With Quote
  #6 (permalink)  
Old 12-14-2004
Anthony Plunkett
 
Posts: n/a
Default Re: quick simple upload

%< Snip >%

> <body>
> <form method="get" enctype="multipart/form-data">
> <input type="file" name="file" />
> <input type="submit" />
> </form>
> </body>
> </html>
>


> http://localhost/mydir/~upload/uploa...%5Caupload.zip
>
> no errors is displayed the page comes back as it was
>
> nothing is uploaded
>
> Jean



As far as I am aware, you cannot upload files using the GET method, you
*must* use POST

Ant.
Reply With Quote
  #7 (permalink)  
Old 12-14-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: quick simple upload

Québec wrote:
> This server dont accept 'post' so I replaced with get
> Where do I set it to POST?Php.ini? Config.inc

[...]
> no errors is displayed the page comes back as it was
>
> nothing is uploaded
>


As Anthony Plunkett pointed out, file uploads only work with the POST
method.

To enable the POST method on the server and when the server is Apache,
search for a <Limit /> section within the <Directory /> section that is
pointing to the website root.

It should look something like this (notice "POST" and "Allow from all"):

<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>

You might also see a <LimitExcept /> section, which should look like this
(notice "POST"):

<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>

See the apache website @ apache.org for more info.


Goodluck
JW



Reply With Quote
  #8 (permalink)  
Old 12-14-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: quick simple upload

Janwillem Borleffs wrote:
> To enable the POST method on the server and when the server is Apache,
> search for a <Limit /> section within the <Directory /> section that
> is pointing to the website root.
>


Just to clearify; this applies to the httpd.conf file in the Apache
installation directory (in the root or in the conf subdir).


JW



Reply With Quote
  #9 (permalink)  
Old 12-14-2004
Québec
 
Posts: n/a
Default Re: quick simple upload

There is none?

----------- snip ---------

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "somethingAnd/www"

#
# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# permissions.
#
<Directory />
AllowPost //JPD
Options FollowSymLinks Indexes
AllowOverride All
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "somethingAnd//www">

#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes FollowSymLinks Includes

#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
----------- snip ---------


Reply With Quote
  #10 (permalink)  
Old 12-14-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: quick simple upload

Québec wrote:
> There is none?

[...]
> <Directory "somethingAnd//www">


It seems that you have your escapes mixed up. In general, you should not mix
backslashes with forward slashes and escape backquotes only, so not:

<Directory "somethingAnd//www">

But:

<Directory "somethingAnd/www">

And not:

$dir = "secret/EasyPHP1-7\www\~uploads\";

But either:

$dir = "secret/EasyPHP1-7/www/~uploads/";

Or:

$dir = "secret\\EasyPHP1-7\\www\\~uploads\\";

When using single quotes, you don't have to escape backslashes:

$dir = 'secret\EasyPHP1-7\www\~uploads\';

It also appears that you are working on a Windows system, in which case, you
should indicate the drive letter also:

<Directory "C:/somethingAnd/www">

This also applies to the DocumentRoot setting and absolute path settings in
your scripts.


JW



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:25 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0