Re: [PHP] File uploading and saving info on mysql

2007-05-04 Thread Marcelo Wolfgang

Richard Lynch wrote:


Browsers will probably NOT populate these reliably...

Mac Safari, might, for example, choose application/x-pdf for the PDF
file.

You really can't rely on 'type' to be useful in any way, shape, or form.



Thanks for the tips, I've deleted this check, and changed how I check 
for the file type in the code.


and I've redone the code to match Jim Lucas suggestion also, it's 
working very nicely right now.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File uploading and saving info on mysql

2007-05-03 Thread Jim Lucas

Marcelo Wolfgang wrote:

Hi all,

I'm developing for my first time an upload file form which will populate 
a sql insert query, I think I got everything working fine, but the data 
isn't been saved on the database. Can someone help me with what I'm 
doing wrong here ?


the code follow:

?php
if (($_FILES[file][type] == application/msword)
|| ($_FILES[file][type] == application/pdf)
 ($_FILES[file][size]  200))
  {
  if ($_FILES[file][error]  0)
{
echo Return Code:  . $_FILES[file][error] . br /;
}
  else
{
if (file_exists(../downloads/ . $_FILES[file][name]))
  {
  echo $_FILES[file][name] .  already exists. ;
  }
else
  {
  move_uploaded_file($_FILES[file][tmp_name],
  ../downloads/ . $_FILES[file][name]);
  }
}
  }
else
  {
  echo Invalid file;
  }
$title = $_POST[title];
$filePath =   ../downloads/ . $_FILES[file][name];
if($_FILES[file][type] == application/pdf){
$fileType = pdf;
} else if ($_FILES[file][type] == application/msword){
$fileType = doc;
}
echo($title) . br /; //outputs 'yada' ( correctly as I've typed on 
the form;
echo($filePath) . br /; //outputs '../downloads/66321-Estrutura.doc' 
and I can check that the file is there;

echo($fileType) . br /; //outputs 'doc' this is correct;

mysql_connect(localhost,$db_user,$db_pass) or die (mysql_error());;
mysql_select_db ($db_table);
$user_Query = mysql_query(INSERT INTO tb_downloads (var_title, 
var_filepath, var_filetype, dt_data, bol_active) VALUES ('$title', 
'$filePath','$fileType','NOW(),1));

You have an error in your SQL statement.
You have a single quote opening just before your NOW() call.

I usually setup my query in a string before I place it in the mysql_query() 
command.

This way I can echo it out and see it before it get executed.

$SQL = INSERT INTO tb_downloads (
var_title,
var_filepath,
var_filetype,
dt_data,
bol_active
) VALUES (
'$title',
'$filePath',
'$fileType',
NOW(),
1
);

echo $SQL;

plus, just for debugging, you should add this to your query line

$user_Query = mysql_query($SQL) or die(SQL Error #[.mysql_errno().]:br 
/\n . mysql_error());



mysql_close();

echo($user_Query) . br /; //outputs nothing (? I suck at debugin 
queries)

this will only output the Result pointer from mysql.

You need to use something like this:


print_r(mysql_fetch_assoc($user_Query));

you might want to look at mysql_num_rows() also.  This will tell you the number of results you got 
back.


Take a look at this example, it will give you all the needed parts to make this 
work

http://us.php.net/mysql_fetch_assoc#id5291494



header(Location: 
http://www.w3ol.com.br/50congresso/adm/downloads.php;); // I know that 
this won't work while I echo something on the page, but the echo is 
there for debug only


?

TIA
Marcelo Wolfgang




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Unknown

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File uploading and saving info on mysql

2007-05-03 Thread Richard Lynch
On Thu, May 3, 2007 3:23 pm, Marcelo Wolfgang wrote:

 I'm developing for my first time an upload file form which will
 populate
 a sql insert query, I think I got everything working fine, but the
 data
 isn't been saved on the database. Can someone help me with what I'm
 doing wrong here ?

 the code follow:

 ?php
 if (($_FILES[file][type] == application/msword)
 || ($_FILES[file][type] == application/pdf)

Browsers will probably NOT populate these reliably...

Mac Safari, might, for example, choose application/x-pdf for the PDF
file.

You really can't rely on 'type' to be useful in any way, shape, or form.

See various recent thread regarding mime_magic and other options.

  ($_FILES[file][size]  200))
{
if ($_FILES[file][error]  0)
  {
  echo Return Code:  . $_FILES[file][error] . br /;
  }
else
  {
  if (file_exists(../downloads/ . $_FILES[file][name]))
{
echo $_FILES[file][name] .  already exists. ;
}
  else
{
move_uploaded_file($_FILES[file][tmp_name],
../downloads/ . $_FILES[file][name]);
}
  }
}
 else
{
echo Invalid file;
}
 $title = $_POST[title];
 $filePath =   ../downloads/ . $_FILES[file][name];
 if($_FILES[file][type] == application/pdf){
   $fileType = pdf;
 } else if ($_FILES[file][type] == application/msword){
   $fileType = doc;
 }
 echo($title) . br /; //outputs 'yada' ( correctly as I've typed on
 the form;
 echo($filePath) . br /; //outputs
 '../downloads/66321-Estrutura.doc'
 and I can check that the file is there;
 echo($fileType) . br /; //outputs 'doc' this is correct;

 mysql_connect(localhost,$db_user,$db_pass) or die (mysql_error());;
 mysql_select_db ($db_table);
 $user_Query = mysql_query(INSERT INTO tb_downloads (var_title,
 var_filepath, var_filetype, dt_data, bol_active) VALUES ('$title',
 '$filePath','$fileType','NOW(),1));

That's not a query, that's a result...

And you aren't checking it to see if it's an error, and you're not
using http://php.net/mysql_error to find out what the error is.

 mysql_close();

 echo($user_Query) . br /; //outputs nothing (? I suck at debugin
 queries)

And once you have closed the connection mysql_close() the result is
GONE, so if you do want to see it, you'd need it to be before the
mysql_close() probably.  It won't be very interesting, really, as it
will be FALSE if your SQL is messed up, and just a number from 1 to N
(where N is the number of queries you have sent) if the query
succeeded.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File Uploading Issue

2004-08-05 Thread Jason Wong
On Thursday 05 August 2004 13:42, PHP E-Mail List wrote:

 You don't have permission to access /directory uploaded
 to/renamed file.txt on this server.

What are the permissions on that file?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If you are smart enough to know that you're not smart enough to be an
Engineer, then you're in Business.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File Uploading Issue

2004-08-05 Thread raditha dissanayake
PHP E-Mail List wrote:
Ok, I figured I'd tackle this since I've been coding php for about 6
months now. And wouldn't ya know, I'm having problems with, what I
thought would be the easiest thing to code ever.  Yeah well I get the
file to upload, and heck I can even take the file and display what text
was uploaded.

However when I go and try tio view the file in that directory. It says:

Forbidden
 

As jason has said this is a permission issue and probably related to 
your umask setting. It's unusual for a file not to have the +r settings 
but can happen. You can most often call the chmod() function to rectify 
this issue on your upload handler.

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] File Uploading Issue

2004-08-05 Thread PHP E-Mail List
Yeah I was at a friends house tonight and we telnetted (if that's a
word) into the server and found that it was set for read only not
execute and so I could see the directory listing but wasn't able to load
the file in the browser.  I figured it was something like this last
night, but with out the telnet to confirm it didn't make immediate
sense.  I'm now in the process of creating a chmod class to allow for
changing of the files based on the logged in user.

Thanks for the responses!
Wolf

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 05, 2004 1:34 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] File Uploading Issue

On Thursday 05 August 2004 13:42, PHP E-Mail List wrote:

 You don't have permission to access /directory uploaded
 to/renamed file.txt on this server.

What are the permissions on that file?

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
If you are smart enough to know that you're not smart enough to be an
Engineer, then you're in Business.
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File Uploading Question

2002-07-10 Thread Justin French

on 11/07/02 10:10 AM, Nick Oostveen ([EMAIL PROTECTED]) wrote:

 I've got a (hopefully) simple question which is indirectly related to php.

Very indirectly.  Infact, it's completely a HTML/CSS question.

Try the comp.infosystems.www.authoring.stylesheets newsgroup.


Justin French


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] File uploading fails

2002-05-01 Thread Pushkar Pradhan

You haven't defined $file_name before trying to echo it, I think you'll
have to create it using $HTTP_POST_...['file'] and HTT...['name']
Also check your php.ini to see if file uploads are allowed and if yes the
max. limit.
 I have searched high and low and done everything
 recommended generically and yet am still having
 problems uploading files. My script is as follows:
 BODY
 ?php
 error_reporting(E_ALL);
 echo phpinfo();
 echo $file_name;
 echo $HTTP_POST_FILES['file']['name'];
 if (isset($file)){
 echo Successfully uploaded , $file_name, BR\n;
 }
 ?
 FORM ACTION=addimage.php METHOD=POST
 enctype=multipart/form-data
 INPUT TYPE=FILE NAME=fileBR
 INPUT TYPE=SUBMIT
 /FORM
 /BODY

 Output is as follows:

 Warning: Undefined variable: file_name in addimage.php
 on line 5

 Warning: Undefined index: file in addimage.php on line
 6

 I get this message with all the variations of file
 upload testing.

 FYI I'm trying to upload a 160K jpg file for testing.

 Using Apache and Linux server. WIN IE Client.

 Help would be greatly appreciated.

 TIA,
 Tim
 unka_timmyATyahoo.com


 __
 Do You Yahoo!?
 Yahoo! Health - your guide to health and wellness
 http://health.yahoo.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-Pushkar S. Pradhan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] File uploading fails

2002-05-01 Thread 1LT John W. Holmes

$HTTP_POST_FILES/$_FILES is provided to contain the uploaded file
information.

The contents of $HTTP_POST_FILES are as follows. Note that this assumes the
use of the file upload name 'userfile', as used in the example script above:


  $HTTP_POST_FILES['userfile']['name']
  The original name of the file on the client machine.

  $HTTP_POST_FILES['userfile']['type']
  The mime type of the file, if the browser provided this information. An
example would be image/gif.

  $HTTP_POST_FILES['userfile']['size']
  The size, in bytes, of the uploaded file.

  $HTTP_POST_FILES['userfile']['tmp_name']
  The temporary filename of the file in which the uploaded file was stored
on the server.


  Note: PHP 4.1.0 or later supports a short track variable $_FILES. PHP 3
does not support $HTTP_POST_FILES.

When register_globals is turned on in php.ini the available variables are as
follows. Note that the following variable names assume the use of the file
upload name 'userfile', as used in the example script above:


  a.. $userfile - The temporary filename in which the uploaded file was
stored on the server machine.

  b.. $userfile_name - The original name or path of the file on the sender's
system.

  c.. $userfile_size - The size of the uploaded file in bytes.

  d.. $userfile_type - The mime type of the file if the browser provided
this information. An example would be image/gif.

Note that the $userfile part of the above variables is whatever the name
of the input field of type=file is in the upload form. In the above
upload form example, we chose to call it userfile.

  Note: register_globals = On is not recommended for security and
performance reason.

Love that manual,

---John Holmes...

- Original Message -
From: Tim Decker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, May 01, 2002 11:13 AM
Subject: [PHP] File uploading fails


 I have searched high and low and done everything
 recommended generically and yet am still having
 problems uploading files. My script is as follows:
 BODY
 ?php
 error_reporting(E_ALL);
 echo phpinfo();
 echo $file_name;
 echo $HTTP_POST_FILES['file']['name'];
 if (isset($file)){
 echo Successfully uploaded , $file_name, BR\n;
 }
 ?
 FORM ACTION=addimage.php METHOD=POST
 enctype=multipart/form-data
 INPUT TYPE=FILE NAME=fileBR
 INPUT TYPE=SUBMIT
 /FORM
 /BODY

 Output is as follows:

 Warning: Undefined variable: file_name in addimage.php
 on line 5

 Warning: Undefined index: file in addimage.php on line
 6

 I get this message with all the variations of file
 upload testing.

 FYI I'm trying to upload a 160K jpg file for testing.

 Using Apache and Linux server. WIN IE Client.

 Help would be greatly appreciated.

 TIA,
 Tim
 unka_timmyATyahoo.com


 __
 Do You Yahoo!?
 Yahoo! Health - your guide to health and wellness
 http://health.yahoo.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] File uploading like hotmail

2002-01-28 Thread Girish Nath

Hi

It's in the manual at :

http://www.php.net/manual/en/features.file-upload.php

Regards


Girish
--
www.girishnath.co.uk


- Original Message - 
From: qartis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, January 28, 2002 6:37 PM
Subject: Re: [PHP] File uploading like hotmail


I think you might be looking for input type=file HTML form element.


Duky Yuen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I want to make something like when you are attaching something to an
 email in hotmail. I want to make something that searches your own
 computer for files on your harddisk that you want to upload to the
 server.

 But I don't know if this is possible. If this is possible.Can somebody
 tell me which function I should use? Or if someone have an example...
 please...

 Duky




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File uploading like hotmail

2002-01-28 Thread Girish Nath

Hi

It's in the manual at :

http://www.php.net/manual/en/features.file-upload.php

Regards


Girish
--
www.girishnath.co.uk


- Original Message - 
From: qartis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, January 28, 2002 6:37 PM
Subject: Re: [PHP] File uploading like hotmail


I think you might be looking for input type=file HTML form element.


Duky Yuen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I want to make something like when you are attaching something to an
 email in hotmail. I want to make something that searches your own
 computer for files on your harddisk that you want to upload to the
 server.

 But I don't know if this is possible. If this is possible.Can somebody
 tell me which function I should use? Or if someone have an example...
 please...

 Duky




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File uploading like hotmail

2002-01-28 Thread qartis

I think you might be looking for input type=file HTML form element.


Duky Yuen [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I want to make something like when you are attaching something to an
 email in hotmail. I want to make something that searches your own
 computer for files on your harddisk that you want to upload to the
 server.

 But I don't know if this is possible. If this is possible.Can somebody
 tell me which function I should use? Or if someone have an example...
 please...

 Duky




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File Uploading

2002-01-21 Thread Jason Wong

On Monday 21 January 2002 10:34, Uma Shankari T. wrote:
 Hello,

   How to upload files in a particular directory using php script in the
  browser itself

The gory details can be found in the chapter Handling File Uploads.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Love is in the offing.
-- The Homicidal Maniac
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File Uploading

2002-01-21 Thread Pedja Delic

Try this:

?php copy($PHP_UPLOADED_FILE_NAME,$DOCUMENT_ROOT.$REQUEST_URI); ?


- Original Message - 
From: Uma Shankari T. [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, January 21, 2002 3:34 AM
Subject: [PHP] File Uploading 


 
 
 Hello,
 
   How to upload files in a particular directory using php script in the
  browser itself
 
 
 Regards,
 Uma
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File Uploading

2002-01-21 Thread Uma Shankari T.




Hello,

   
When i upload the file it is updating only in the document root
directory.It is not updated in some other directory except the root
directory.why is it so?

Any one tell me the solution for this?


Regards,
Uma


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File Uploading

2002-01-21 Thread Nick Wilson

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


* On 21-01-02 at 14:24 
* Uma Shankari T. said

 Hello,
 

 When i upload the file it is updating only in the document root
 directory.It is not updated in some other directory except the root
 directory.why is it so?
 
 Any one tell me the solution for this?
 

Not saying I can help but a little code snippet would give me a fighting
chance ;)
- -- 

Nick Wilson

Tel:+45 3325 0688
Fax:+45 3325 0677
Web:www.explodingnet.com



-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8TBfTHpvrrTa6L5oRAtgHAJ97Jl0D4dsfYMzUBewZv7NVYPG30ACgmy5z
EQiAEqMJ1BOlHhW1dMzBREw=
=8fqH
-END PGP SIGNATURE-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File Uploading

2002-01-21 Thread Jason Wong

On Monday 21 January 2002 21:17, Uma Shankari T. wrote:
 Hello,


 When i upload the file it is updating only in the document root
 directory.It is not updated in some other directory except the root
 directory.why is it so?

 Any one tell me the solution for this?

The general procedure for dealing with uploaded files is:

1) Uploaded file is saved in a temp directory (defined in php.ini) under a 
temp name.

2) Get the temp name and the actual name (see manual).

3) Move the temp file to its final destination.


The final destination directory must be writable by the 'user' running the 
webserver.

hth
-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
The human race has one really effective weapon, and that is laughter.
-- Mark Twain
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] file uploading = dumping into ram?

2002-01-03 Thread Chris Lee

set your max upload file size smaller then. default is 2mb max. I find that
too small, I re-set mine to 5mb. I have 2g of ram on our server, 5mb isnt a
worry to me. Id rather that then the slow speed of writing the file to the
hd.

--

  Chris Lee
  [EMAIL PROTECTED]



David [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hi all,

 I wes doing some file upload stuff with php when i noticed that as the
file is being uploaded, the entire file is stored in ram until it\'s
finished.

 obviously, we know the problems associated with this(use up a lot of ram
for large files), i\'m just wondering, is this going to be fixed soon in the
next release of php?

 i think those people using php to upload large files will be very happy if
it\'s fixed :)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re: [PHP] file uploading = dumping into ram?

2002-01-03 Thread David

 thanks, i know what u mean, but what if you have to upload bigger files? 

is it possible that maybe the next php release will have a option to auto write the 
uploading file to disk(if the file being uploaded is bigger than a certain size) while 
uploading instead of slurping the entire file into ram.

just a suggestion for improvement. :)

set your max upload file size smaller then. default is 2mb max. I find that
too small, I re-set mine to 5mb. I have 2g of ram on our server, 5mb isnt a
worry to me. Id rather that then the slow speed of writing the file to the
hd.

-- 

Chris Lee
[EMAIL PROTECTED]



\David\ [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hi all,

 I wes doing some file upload stuff with php when i noticed that as the
file is being uploaded, the entire file is stored in ram until it\'s
finished.

 obviously, we know the problems associated with this(use up a lot of ram
for large files), i\'m just wondering, is this going to be fixed soon in the
next release of php?

 i think those people using php to upload large files will be very happy if
it\'s fixed :) 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File uploading?

2001-01-31 Thread Ben

Lauri,

supposing you name the file input tag "myfile" (like INPUT NAME="file"
TYPE="myfile"), then

$myfile contains the name of the temporary file on the server, while
$myfile_name contains the filename on the client's system.

See also
http://www.php.net/manual/en/features.file-upload.php

Drop me a line if you are still stuck,
Ben

Lauri Vain wrote:
 
 Hello everybody,
 
 I'm trying to do a file upload from the users computer via HTML file form element
 to a Linux server running Apache. The file is selected by the user from her
 or his computer, they hit the submit button and the file goes to /print/ folder
 (dir relative to uploading script on the server). I use the following code:
 
 
 /**Upload'i file*/
 function upload($file)
 {
 $name = split("",$file); // Get filename
 $name = end($name);
 
 $fd = fopen($file, "w+");/*BTW, this is line 12 */
  $filedata = addslashes(fread($fd, filesize($pilt)));
  fputs("/print/$name", stripslashes($filedata));
 fclose($fd);
 
 /*copy($file,"print/".$name);   Kopeeri fail kausta
 fputs($fp, $header);
 fclose($fp);
 unlink($file);*/
 return $name;
 }
 /**Upload'i file*/
 
 I get the following error code:
 / ERROR */
 Warning: fopen("C:\\Data\\Lauri\\Selja_seadused.doc","w+") - Permission denied
 
 in /home/saue/public_html/oigusaktid/funktsioonid.php3 on line 12
 
 Warning: Supplied argument is not a valid File-Handle resource in
 /home/saue/public_html/oigusaktid/funktsioonid.php3 on line 13
 
 Warning: Supplied argument is not a valid File-Handle resource in
 /home/saue/public_html/oigusaktid/funktsioonid.php3 on line 14
 
 Warning: Supplied argument is not a valid File-Handle resource in
 /home/saue/public_html/oigusaktid/funktsioonid.php3 on line 15
 / ERROR */
 
 Thanks for your help in advance!
 
 Yours truly,
 Lauri
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] File uploading?

2001-01-31 Thread James Smith

Here is the code i'm running for my file upload and it
work correctly:
// file with submit form
form name="postfile" method="post"
action="./postfile.php" enctype="multipart/form-data"
input type="hidden" name="MAX_FILE_SIZE"
value="1000"
input type="file" name="name of var" size="x"
input type="submit" name="submit" value="submit"
/form

// This is the file that you want to use as post
// example is postfile.php

?php
copy($name of var_name, "/full/path/$name of var");
?

// That will copy the file.

here is the full function I have implemented with my
page to store path into mysql.

function
upload_prog($file,$filename,$des,$name,$size,$dateadded,$addedby,$type)
{
copy($file, "c:/full/path/to/dir/$filename");
$result = mysql_query("INSERT INTO
tablename(prog_name,prog_size,prog_des,prog_url,prog_date_added,added_by,prog_type)
VALUES
('$name','$size','$des','./filez/$filename','$dateadded','$addedby','$type')");
$id = mysql_insert_id();
$result = mysql_query("SELECT * FROM tablename WHERE
id='$id'");
$myrow = mysql_fetch_array($result);
}

// this will store the path into the MySQL and you can
use it as a link.

Hope this helps you.

James

__
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] File Uploading Security - Urgent please

2001-01-11 Thread Matt Williams


if(ereg("jpg|jpeg|gif$",$userfile_name))
{
do something
}
else
{
this file is not allowed
}
This will check that the uploaded file has the correct extension.

Where $userfile is the upload field name in the form

M@
 -Original Message-
 From: Statbat [mailto:[EMAIL PROTECTED]]
 Sent: 11 January 2001 11:00
 To: PHP-General
 Subject: [PHP] File Uploading Security - Urgent please
 
 
 Hello,
 
 I am doing file uploading of only jpg file format, It first copys 
 in tmp directory then I copy it in main well you all know the 
 procedure... neways what I am concerned is how can I check that 
 the file in temp is correct file and is safe for me to copy it in 
 the main folder?
 
 Regards
 Statbat
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] File Uploading Security - Urgent please

2001-01-11 Thread Moritz Petersen

$userfile_type

contains the MIME-type of the file. This is maybe more relieable then just
the extension...

Mo.

 if(ereg("jpg|jpeg|gif$",$userfile_name))
 {
   do something
 }
 else
 {
   this file is not allowed
 }
 This will check that the uploaded file has the correct extension.

 Where $userfile is the upload field name in the form

 M@
  -Original Message-
  From: Statbat [mailto:[EMAIL PROTECTED]]
  Sent: 11 January 2001 11:00
  To: PHP-General
  Subject: [PHP] File Uploading Security - Urgent please
 
 
  Hello,
 
  I am doing file uploading of only jpg file format, It first copys
  in tmp directory then I copy it in main well you all know the
  procedure... neways what I am concerned is how can I check that
  the file in temp is correct file and is safe for me to copy it in
  the main folder?
 
  Regards
  Statbat
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]