FILE UPLOAD TRHOUGH FORMS, how to delete POST files

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

FILE UPLOAD TRHOUGH FORMS, how to delete POST files

Post by Eugene »

I have a form through which users can upload file.

After the file has been handled by my php script, a page is displayed where it is indicated that the file has been received. I then use the BACK button in the browser, but get back to the page where it says that the file was submitted (I want to come back to page with the form!!!).

In fact, the form and the file handling is all done in one php file, that calls itself upon a POST event. There is check in the code:

Code: Select all

if (is_uploaded_file($_FILESї'imageFile']ї'tmp_name']))
and at the end I try to get rid of that file by doing:

Code: Select all

unset($_FILESї'imageFile']ї'tmp_name']);
It does not seem to work.

I also tried just doing

Code: Select all

unset($_FILES);
Can somebody help me???
Thanks
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

UPDATE, using REFRESH works

Post by Eugene »

UPDATE

When I use the REFRESH button in the browser, after the file has been processed, the form is displayed correctly.

Using BACK still doesnt work.

I dont understand why it is acting like this.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Do you get an an message window with something like "outdated, needs refresh"? when you hit the back-button?
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

no, there is no message

is it possible that the BACK action actually re-submits the form??????
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

yes, but my browser asks me before doing that....
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

I read somewhere that at the end of a POST session (when the file specified in the ACTION option finishes running) the POST variables are suposed to be removed from the temporary directory of the web server.

Is that true?????


Can I somehow force delete the POSTED information and file??????
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

POST-data is sent from client to browser and not necessarily stored at the server. PHP stores POST/file-upload data in a temp. directory but not the post-vars. Unsetting them is useless since the browser will sent them again. Take a look at this board how it (tries to) prevents double posts using the back-button ;)
User avatar
Eugene
Forum Newbie
Posts: 24
Joined: Tue Jun 18, 2002 12:40 pm
Location: Montreal

Post by Eugene »

:D :D Very true

I explored a bit how the client-server interaction:

Pressing the refresh button actually resubmits the form (there is a message that appears, asking if I want to resubmit)

Pressing back, the form re-appears with the fields filled in, but the information is not sudmitted. Somehow,

Code: Select all

is_uploaded_file($_FILESї'imageFile']ї'tmp_name'])
still return true however.

But I think I am worrying for nothing. I made my script such that after a file has been submitted, the form re-appears again, so people can submit other files. And if they want to leave that section I hope that they will use links and not press the back button

thank you very much

PS: I actually have another question, about MySQL this time. Is there a way of ordereing the entries in a database alphabetically (using names for example)???
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

if(isset($_FILESї'imageFile']) && !empty($_FILESї'imageFile']ї'size']) 
   && is_uploaded_file($_FILESї'imageFile']ї'tmp_name']) )
the order created by ORDER BY for a string-field is alphabetically
http://www.mysql.com/documentation/mysq ... ote]Values in CHAR and VARCHAR columns are sorted and compared in case-insensitive fashion, unless the BINARY attribute was specified when the table was created. The BINARY attribute means that column values are sorted and compared in case-sensitive fashion according to the ASCII order of the machine where the MySQL server is running. BINARY doesn't affect how the column is stored or retrieved.

The BINARY attribute is sticky. This means that if a column marked BINARY is used in an expression, the whole expression is compared as a BINARY value.[/quote]
Post Reply