Re: Problem uploading files

From: Date: Fri, 04 Oct 2002 16:21:50 +0000
Subject: Re: Problem uploading files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118887@lists.php.net to get a copy of this message
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 (wilmar.perez@caribe.udea.edu.co) 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: > > <form enctype="multipart/form-data" name="book_add" > method="post" > action=".$PHP_SELF."?management=5> > <input type="hidden" name="MAX_FILE_SIZE" value="2000"> > <table width="100%" border="0" bgcolor="#CCCCCC"> > <tr> > <td width="51%">Book Name:</td> > <td width="49%"><input type="text" name="form_title" > size="40"></td> > </tr> > <tr> > <td width="51%">File:</td> > <td width="49%"><input type="file" > name="formfile"></td> > </tr> > <tr align="center"> > <td width="51%"><input type="reset" name="reset" > value="Clean"></td> > <td width="49%"><input type="submit" name="submit" > value="Add new book"></td> > </tr> > </table> > </form> > > > 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 > ******************************************************* > >

« previous php.general (#118887) next »