Jump to content

Recommended Posts

and i don't want to use empty($_FILES['myfile']['name']) because it'll indirectly upload it to my server, right?

 

so, how can i detect this field is empty?

 

It uploads the file to your server once they push submit before the form is processed. It is simply stored in a "temp" directory until you move the file. So doing that test on the name is fine, you could even just do this:

if (isset($_FILES['myfile']))

 

If that is set then they attempted to upload a file via that form/field. But yea, the file is already on the server. After the script is ran it is deleted, hence if you did not move the file before then it is wiped from the server.

and i don't want to use empty($_FILES['myfile']['name']) because it'll indirectly upload it to my server, right?

 

so, how can i detect this field is empty?

 

It uploads the file to your server once they push submit before the form is processed. It is simply stored in a "temp" directory until you move the file. So doing that test on the name is fine, you could even just do this:

if (isset($_FILES['myfile']))

 

If that is set then they attempted to upload a file via that form/field. But yea, the file is already on the server. After the script is ran it is deleted, hence if you did not move the file before then it is wiped from the server.

 

so, you meant that when i'm using

if(empty($_FILES['myfile']['name']) )

 

then the file will be uploaded to server's temp directory...

but, then if my code didn't take any action to the file, when the file will be removed from temp?...i'm not too understand...

 

thanks!

when you upload a file, if it fits in the limts set in php.ini (ie max_filesize etc)

then the file goes to tmp,, this happens before your script starts

ie

1. Form is submitted

2. files are uploaded

3. action script is tiggered

4. action script does the move from $_FILES['var']['tmp_name'] to path you choose

 

So before you make the move you check to see if the uploaded file has a tmp name ($_FILES['var']['tmp_name']), if not then the file wasn't uploaded,

of couse you can also check the error ie

if($_FILES['var']['error'] == 0)
{
# upload is fine
}

 

i hope that helps!

No.. it will not "cause" it, clicking the submit button does!

1. display form

2. submit form (file get uploaded here)

3. the form tiggers the (php) script in actions.

 

So by the time the php has started the file is already in temp!

 

when you upload a file, if it fits in the limts set in php.ini (ie max_filesize etc)

then the file goes to tmp,, this happens before your script starts

ie

1. Form is submitted

2. files are uploaded

3. action script is tiggered

No.. it will not "cause" it, clicking the submit button does!

1. display form

2. submit form (file get uploaded here)

3. the form tiggers the (php) script in actions.

 

So by the time the php has started the file is already in temp!

 

when you upload a file, if it fits in the limts set in php.ini (ie max_filesize etc)

then the file goes to tmp,, this happens before your script starts

ie

1. Form is submitted

2. files are uploaded

3. action script is tiggered

 

thanks for the explanation.

actually, my main purpose is not to upload the picture file, but only to check whether the file input field is selected with a picture. the upload process will be taken care by phpmailer later. so, my logic is something like this:

 

if ($_FILES['myfile']) { //if the field is selected with picture

       calling phpmailer // it'll upload the file later

}else{

        error message to tell user to select a picture for file input field

}

 

so, my worries is if $_FILES['myfile'] will upload my file to temp, later my phpmailer upload again, then causing my server space being not enough...as i have 5 file input fields to check...and i'm not sure when will those files uploaded to temp will be removed...

if many users perform the function(it's a submit form), then more and more server space will be utilized in this case?

 

Okay.. i give..

can you show me the code that does the upload from phpmailer.. infact show me any phpcode that does an upload!

 

oh, the one i used is phpmailer-fe which can be freely download online...in this case, i have to use several of it's file, but the main php file that manage the email is phpmailer-fe.php...actually, i tried before to find from the code, whether i can control the max file size that i can attached to the email, but don't know where to modify as i'm a newbie in php and programming...if you can help me, it's really great. but, i don't think i can paste all the code here because it's too long. or can i send you the file?

okay lets see if we can clear this thread!

 

#1 your starting question

hi, i have a file input type, how can i detect it as empty...

i don't want to use empty($_FILES['myfile']['name']) because it'll indirectly upload it to my server, right?

WRONG! it doesn't see all my posts above!

Summary (the files will be uploaded from the form and ONLY then php handles it..)

 

so, how can i detect this field is empty?

#2 you know, use

empty($_FILES['myfile']['name'])

 

 

actually, i tried before to find from the code, whether i can control the max file size that i can attached to the email,

#3 phpmailer (yes i know it well) sends emails it has nothing todo with uploading files, attachments yes but not uploads

#4 Max filesize of an attachment is based on the ISP's limit! not the email build!

 

okay lets see if we can clear this thread!

 

#1 your starting question

hi, i have a file input type, how can i detect it as empty...

i don't want to use empty($_FILES['myfile']['name']) because it'll indirectly upload it to my server, right?

WRONG! it doesn't see all my posts above!

Summary (the files will be uploaded from the form and ONLY then php handles it..)

 

so, how can i detect this field is empty?

#2 you know, use

empty($_FILES['myfile']['name'])

 

 

actually, i tried before to find from the code, whether i can control the max file size that i can attached to the email,

#3 phpmailer (yes i know it well) sends emails it has nothing todo with uploading files, attachments yes but not uploads

#4 Max filesize of an attachment is based on the ISP's limit! not the email build!

 

thanks for the reply!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.