Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Uploading Files Using PHP in Linux......


Message #1 by "Vamshidhar" <vamshimt@y...> on Tue, 1 Oct 2002 09:30:15
Hi,
	I am specifying the script to be uploaded.

upload_form.html
----------------
<HTML>
<HEAD>
<TITLE>Upload a File</TITLE>
</HEAD>
<BODY>
<H1>Upload a File</H1>
<FORM METHOD="post" ACTION="do_upload.php" ENCTYPE="multipart/form-data">
<P><STRONG>File to Upload:</STRONG><BR>
<INPUT TYPE="file" NAME="img1" SIZE="30"></P>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Upload File"></P>
</FORM>
</BODY>
</HTML>
do_upload.php
-------------
<?
if($img1_name != "")  {
@copy("$img1", "/usr/apache/htdocs/org/$img1_name") or die("Couldn't copy
the file.");
} else {
        die("No input file specified");
}
?>
<HTML>
<HEAD>
<TITLE>Successful File Upload</TITLE>
</HEAD>
<BODY>
<H1>Success!</H1>
<P>You sent: <? echo "$img1_name"; ?>, a <? echo "$img1_size"; ?>
byte file with a mime type of <? echo "$img1_type"; ?>.</P>
</BODY>
</HTML>

NOTE:-
-----
The permission for "usr, apache, htdocs" directory are 755 permission.
The permission for "tmp" directory is 777 permission.

 	I am running as nobody.For example I am uploading the file 
 to /usr/apache/htdocs/org directory from any remote machine.
 The permission for "usr, apache, htdocs" directory are 755 permission.
 The permission for "org" directory is 777 permission. 
 My script to be upload is residing in /usr/apache/htdocs/upload directory.
 The permission for "usr, apache, htdocs and upload" directory are 755 
 permission.
 Also the script permission is 755 permission.
 i.e scripts are upload_form.html, do_upload.php.
 For me uploading images works.
 
 Regards,
 S.Arun Srinivasan.
 
> > >         These are the following steps to be done
> > > when uploading a file
> > > to your website from a remote location using PHP.
> > > 
> > > Before you start uploading files,check few values in
> > > php.ini file.
> > > Look for these 2 lines:
> > > 
> > > ;upload_tmp_dir =  ;temporary directory for HTTP
> > > uploaded files.
> > > upload_max_filesize = 2097152 ; 2 Meg default limit
> > > on file uploads
> > > 
> > > You'll need to modify these lines so that the file
> > > upload process
> > > will work smoothly.
> > > 
> > > 1.Uncomment the upload_tmp_dir line by deleting the
> > > initial semicolon.
> > > 
> > > 2.Enter a directory name after the = for
> > > upload_tmp_dir
> > > 
> > > 3.If u want to allow larger uploads,change the no of
> > > bytes for
> > > upload_max_filesize
> > > 
> > > For example "php.ini" file in linux u can specify as
> > > follows
> > > 
> > > upload_tmp_dir = /usr/apache/htdocs/tmp ;
> > > temporary directory for HTTP
> > >                                              
> > > uploaded files
> > > upload_max_filesize = 2097152    ; 2 Meg default
> > > limit on file uploads
> > > 
> > > NOTE
> > > ****
> > > PHP user(the user under which php runs such as
> > > "nobody" or "www" or "joe")
> > > must have write permissions in temporary directory
> > > as well as target
> > > directory for the file.


  Return to Index