Re: uploading files after passing vars between forms

From: Date: Thu, 12 Jun 2003 17:02:50 +0000
Subject: Re: uploading files after passing vars between forms
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-151280@lists.php.net to get a copy of this message
I didn't know that Thanks for the info. "Marek Kilimajer" <kilimajer@webglobe.sk> wrote in message news:3EE8ABB8.6030402@webglobe.sk... > Don't forget uploaded files are removed after confirmation.php finishes. > You need to move them to a temporary directory. > > Artoo wrote: > > Hey > > > > I'm confused! > > > > Do I use move_uploaded_file() or copy() and what is the first parameter of > > both in the following case: > > > > form portion of upload.htm > > ------------------------------------------ > > <FORM NAME="Uploading" ENCTYPE="multipart/form-data" > > ACTION="confirmation.php" METHOD="POST" onSubmit="return > > validate()" > > > <input name="superdat" type="file" size=30> > > <INPUT TYPE="hidden" name="MAX_SIZE" value="100000"> > > <INPUT TYPE="hidden" name="filepath"> > > <input type=submit name=submit value="Click here for preview"> > > </FORM> > > > > Upload.htm asks for the image to be uploaded and passes of to > > confirmation.php which allows the user to either send the photo or go back > > and change the photo. and uses hidden values to pass the variables form > > upload.htm > > > > form prortion of confirmation.php > > -------------------------------------------- > > <form action="send_file.php" method="post" enctype="multipart/form-data"> > > <? print "<img src=\"$filepath\" width=\"100\" > > hight=\"80\">";?></div> > > <p align="center"> > > <input type=submit NAME="send_photo" value="Send to server!"> > > <input > > type="button" name="edit" value="Chage the photo" onClick="history.go(-1)"> > > <input type="hidden" name="superdat" value="<?php echo > > $superdat; ?>"> > > <input type="hidden" name="temp_name" value="<?php echo > > $_FILES['superdat']['tmp_name']; ?>"> > > <input type="hidden" name="file_name" value="<?php echo > > $_FILES['superdat']['name']; ?>"> > > <input type="hidden" name="file_size" value="<?php echo > > $_FILES['superdat']['size']; ?>"> > > <input type="hidden" name="MAX_SIZE" value="100000"> > > </form> > > <input type="hidden" name="temp_name" value="<?php echo > > $_FILES['superdat']['tmp_name']; ?>"> > > <input type="hidden" name="file_name" value="<?php echo > > $_FILES['superdat']['name']; ?>"> > > <input type="hidden" name="file_size" value="<?php echo > > $_FILES['superdat']['size']; ?>"> > > <input type="hidden" name="MAX_SIZE" value="100000"> > > </form> > > > > Then send_file.php first cheks to see if the user had pressed the "send to > > server" button. I still have to work on the "Change the photo" button. > > > > If "send to server" was pressed, 'send_file.php' first checks to see > > if that > > file already exists on the server. If it does it displays a message to the > > user. If it does not exist, the file is copied onto the server. > > > > send_file.php > > > > > > PHP: > > -------------------------------------------------------------------------- -- > > -- > > > > <? $path="/usr/local/home/website1/httpdocs"; > > $file_path = $path."/images/".$file_name; > > if($_POST['send_photo']) > > { > > if (file_exists($file_path)) > > { > > ?> </div><h1><strong><? echo "$file_name"; ?>, > > already > > exists.</strong></h1><h2> > > <? exit(); > > } > > if ( copy($file_name, $file_path) ) > > { > > ?><h1><P></P>Thank you for <? echo "$file_name"; > > ?>. Your uload has > > succesfully uploaded.</h1><? > > } > > else > > { > > print "ERROR"; > > exit(); > > } > > } > > > > -------------------------------------------------------------------------- -- > > -- > > > > > > > > I get " Warning: Unable to open '' for reading: No such file or > > directory..." > > > > I did have print statements for each of the vars being passed into > > send_file.php to make sure they were seen. And they were. > > > > What fucntion should I use the move_uploaded_file() or copy() and what's the > > function's first argument so that the file is copied to the server? > > > > Thanks > > > > > > >

« previous php.general (#151280) next »