RE: [PHP-DB] File input from form not detected

2003-06-02 Thread Dewi Wahyuni
Hi everyone 


I changed the code a bit. Using the file tmp now.

Here's the code and the error (still error but less) 

Thanks for the help



upload.php

-
?
phpinfo();
echo $_POST['userfile']['tmp'];
if (is_uploaded_file($_POST['userfile'])) 
   copy($userfile, $HTTP_POST_FILES['userfile']['name']);
else  echo error. File: $userfile.; 

$filename=$HTTP_POST_FILES['userfile']['name']; 
$fd = fopen ($_FILES[userfile][tmp_name], rb);
$contents = fread ($fd, filesize($filename));
fclose($fd);
$escaped_contents=mysql_escape_string($contents);
// Connecting, selecting database
$link = mysql_connect(localhost, ,);
mysql_select_db(bus8646,$db);
// Performing SQL query; assuming that the picture is a BLOB field
$query = UPDATE studentpart SET pic='$escaped_contents' WHERE loginname='lulu';
$result = mysql_query($query)
   or die(Query failed);
// Closing connection
mysql_close($link);
?


error code 
--
error. File: /tmp/phpObl8LE.
Warning: filesize() [function.filesize]: Stat failed for b_about.gif (errno=2 - No 
such file or directory) in /home/bus8646/www/tryout/upload.php on line 10

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in 
/home/bus8646/www/tryout/upload.php on line 15
Query failed





Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005

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



Re: [PHP-DB] File input from form not detected

2003-06-01 Thread Dewi Wahyuni
Hi everyone thanks.
I did add the enctype but it's still not working. Here're
 the codes
Sorry if I posted to the wrong list. because I was trying to store the file as well in 
the mysql db blob. Someone suggested to print all the $ post vars as I print, only the 
MAX_FILE_SIZE shows up as a variable. I also tried directy assigning $userfile = C: 
blabla and it gives the same thing
 
One more thing do I have to use base_64 encode for this ? 

upload.html
---
html
body
FORM ACTION=upload.php METHOD=POST  enctype=multipart/form-data name=upload 
id=upload
  INPUT TYPE=hidden name=MAX_FILE_SIZE value=65000
  Send this file: 
  input type=file name=userfile
  INPUT TYPE=submit VALUE=Upload file
/FORM
/body
/html

upload.php
--

?
phpinfo();

   echo $_POST['userfile']['tmp'];  // never got echoed it seems to be empty.

   if (is_uploaded_file($userfile)) 
copy($userfile, $HTTP_POST_FILES['userfile']['name']);
   else  echo error. File: $userfile.; // this is invoked  but it can't print 
$userfile either. 

   $filename=$HTTP_POST_FILES['userfile']['name']; 

   $fd = fopen ($filename, rb);

   $contents = fread ($fd, filesize($filename));

   fclose($fd);

   $escaped_contents=mysql_escape_string($contents);
  // Connecting, selecting database

   $link = mysql_connect(localhost, **,**);
mysql_select_db(**,$db);
   
   // Performing SQL query; assuming that the picture is aBLOB field
   
   $query = UPDATE studentpart SET pic='$escaped_contents' WHERE 
loginname='lulu';
   $result = mysql_query($query)
   or die(Query failed);
   // Closing connection
   mysql_close($link);
?

errors example filename tried to upload is c:\\windows\Backgrnd.gif


error. File: .
Warning: fopen(Backgrnd.gif) [function.fopen]: failed to create stream: No such file 
or directory in /home/bus8646/www/tryout/upload.php on line 9

Warning: filesize() [function.filesize]: Stat failed for Backgrnd.gif (errno=2 - No 
such file or directory) in /home/bus8646/www/tryout/upload.php on line 10

Warning: fread(): supplied argument is not a valid stream resource in 
/home/bus8646/www/tryout/upload.php on line 10

Warning: fclose(): supplied argument is not a valid stream resource in 
/home/bus8646/www/tryout/upload.php on line 11
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in 
/home/bus8646/www/tryout/upload.php on line 15

Query failed





Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005

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



[PHP-DB] File input from form not detected

2003-05-31 Thread Dewi Wahyuni

Hi, following my earlier post

My input file from form in eg upload.html was not detected in the upload.php (handler)

The example can be seen in http://www.busybees.com.my/tryout/upload.html

I tried uploading using the input type=file name=userfile

which is supposed to be captured by the php as $userfile (as far as I know) but 
whenever I put 

if($userfile) it fails. BUT $userfile_name is able to  display the filename . 

With print_f($HTTP_POST_VARS) also the userfile was not displayed, only other input 
element which is Maximum file size is displayed 

My register_globals is 'on' as you can see if you try the example in the above url. I 
have given the phpinfo() in upload.php

I can handle all other data from forms except files.

Please help
THank you
Dewi




Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005

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



Re: [PHP-DB] File input from form not detected

2003-05-31 Thread Paul Burney
on 05/30/2003 9:16 AM, Dewi Wahyuni at [EMAIL PROTECTED] appended the following
bits to my mbox:

 if($userfile) it fails. BUT $userfile_name is able to  display the filename .
 
 With print_f($HTTP_POST_VARS) also the userfile was not displayed, only other
 input element which is Maximum file size is displayed

Hi Dewi,

I think you posted to the wrong list.  You should probably be posting to
PHP-GENERAL.

Have you read through the manual page and all of the comments yet?

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

Some tips:

- If you are using PHP 4.1 or above, you should probably be looking at the
$_FILES array.

- You must add an encoding type to the form - enctype=multipart/form-data

HTH.

Sincerely,

Paul Burney
http://paulburney.com/

?php

// the statement formerly known as prince
if ($the_elevator == 'tries to bring you down') {
go_crazy('punch a higher floor');
} 

?



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



RE: [PHP-DB] File input from form not detected

2003-05-31 Thread Hutchins, Richard
If I understand your post and desired outcome correctly, I think the problem
would lie in the upload.php file. You may need to post the code from that
file for anybody to really help you out.

Rich

 -Original Message-
 From: Dewi Wahyuni [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 30, 2003 9:17 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] File input from form not detected 
 
 
 
 Hi, following my earlier post
 
 My input file from form in eg upload.html was not detected in 
 the upload.php (handler)
 
 The example can be seen in 
 http://www.busybees.com.my/tryout/upload.html
 
 I tried uploading using the input type=file name=userfile
 
 which is supposed to be captured by the php as $userfile (as 
 far as I know) but whenever I put 
 
 if($userfile) it fails. BUT $userfile_name is able to  
 display the filename . 
 
 With print_f($HTTP_POST_VARS) also the userfile was not 
 displayed, only other input element which is Maximum file 
 size is displayed 
 
 My register_globals is 'on' as you can see if you try the 
 example in the above url. I have given the phpinfo() in upload.php
 
 I can handle all other data from forms except files.
 
 Please help
 THank you
 Dewi
 
 
 
 
 Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
 http://login.mail.lycos.com/r/referral?aid=27005
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP-DB] File input from form not detected

2003-05-31 Thread Paul Burney
on 05/30/2003 9:16 AM, Dewi Wahyuni at [EMAIL PROTECTED] appended the following
bits to my mbox:

 if($userfile) it fails. BUT $userfile_name is able to  display the filename .

I just tried the script on your site...

It looks like you are trying to fopen the actual file name.  You need to
fopen the temp file name, i.e., $_FILES[userfile][tmp_name], usually
something like /tmp/phpCcDfs.

HTH.

Paul


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