Re: [PHP] Problem uploading files other than text/plain ones

2002-12-02 Thread Andre Dubuc
Hi Wilmar,

Check whether you have something similar:



You'll definetly need that for antything other than text/plain ones..

Here's a some code that works for me (uploading jpgs):

if ($_FILES["pix"]["size"] > 0){
if ($_FILES["pix"]["type"] == "image/jpeg"){
$pix_file = $_FILES["pix"]["name"];
$pix_temp_file = $_FILES["pix"]["tmp_name"];
$new_pix_file = "new_name.jpg";
if(is_uploaded_file($pix_temp_file)){
move_uploaded_file($pix_temp_file, "pix/$new_pix_file");
}
}
}

Hth,
Andre

On Monday 02 December 2002 11:41 am, Wilmar Perez wrote:
> Hello guys
>
> I'm trying to do a simple task: upload files.  However, when I try to
> upload files other than text/plain ones I get an empty $_FILES array.  Is
> there anything I've got to modify in my php.ini file?  I'm just following
> the expample in the php manual, the only thing different is that I process
> the upload task with a function:
>
> function upload_file($_POST, $_FILES)
> {
>   //The same code as in the php manual
>   return true;  //If everything went ok
> }
>
> if (upload_file($_POST, $_FILES))
>echo "The file has been uploaded";
> else
>echo "Sorry, try again";
>
>
> It works fine with text/plain files, so, am I overlooking anything here?
>
> Thanks a lot
>
> ***
>  Wilmar Pérez
>  Network Administrator
>Library System
>   Tel: ++57(4)2105962
> University of Antioquia
>Medellín - Colombia
>   2002
> ***

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




RE: [PHP] Problem uploading files other than text/plain ones

2002-12-02 Thread Keith Sauvant
You know about the php.ini option "upload_max_filesize"? Perhaps its
default value is not enough for your task?

Greeting from
Keith
Aachen, Germany


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




Re: [PHP] Problem uploading files

2002-10-04 Thread Wilmar Perez

Hello

Justin, thanks for your comments.  Well just to answer your questions:

1.  I've got register_globals set to ON.  I have never had problem before 
with my forms, but this is the first time I try to upload a file.

2.  I'm following the sample code you recommend.  They're in fact pretty 
simmilar .

Thanks a lot again.

***
 Wilmar Pérez
 Network Administrator
   Library System
  Tel: ++57(4)2105145
University of Antioquia
   Medellín - Colombia
  2002
***
 
 

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




Re: [PHP] Problem uploading files

2002-10-04 Thread Justin French

A few observations:

if ($formfile == "none")
{
echo "There is no file to send";
exit;
}

for starters, I don't see how $formfile could ever be "none"... secondly, if
you have register_globals set to off in your php.ini, $formfile wont' even
be a variable, but you've only sent what looks like partial code, so I can't
be sure.


Can I recommend you try to get the perfectly good, working example of file
uploads working that is available on this page:

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


Once you get it working, you can tweak it to suit your needs, rather than
reinventing the wheel over and over... just improve on it.


Justin






on 05/10/02 2:04 AM, Wilmar Perez ([EMAIL PROTECTED]) wrote:

> Hello guys
> 
> This is my first post to the list, hope you can give point me to the right
> direction.
> 
> Well, I've been trying to upload a file without much success so far.
> 
> All I get is my firs error message: "There is no file to send" (shown in the
> script).
> 
> This is my form:
> 
>  action=".$PHP_SELF."?management=5>
> 
> 
>  
> Book Name:
> 
> 
>  
> File:
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> And this is the script that handles the data:
> 
> 
> if ($formfile == "none")
> {
> echo "There is no file to send";
> exit;
> }
> 
> if ($formfile_size == 0)
> {
> echo "Bad file size";
> exit;
> }
> 
> if ($formfile_type != "application/pdf")
> {
> echo "Non a PDF file";
> exit;
> }
> 
> if (!is_uploaded_file($formfile))
> {
> echo "Warning!!!";
> exit;
> }
> 
> $upfile = "/var/www/bva/new/pdf/".$formfile_name;
> 
> 
> if (!copy($formfile, $upfile))
> {
> echo "There was a problem moving the file to the repository";
> exit;
> }
> else
> {
> echo "New book has been uploaded";
> exit;
> }
> 
> 
> 
> 
> Thanks a lot for your help.
> 
> 
> ***
> Wilmar Pérez
> Network Administrator
> Library System
> Tel: ++57(4)2105145
> University of Antioquia
> Medellín - Colombia
> 2002
> ***
> 
> 


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