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, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 > > > |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
%< 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. |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 --------- |
|
|||
|
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 |