The important part here is the enctype, always have the enctype specified if you're uploading files. The first paragraph is the little Loading... box that'll show up when we press the submit button. The second <p> "result" is to display the results (We've uploaded or We failed). And lastly the iframe that is actually submitting the data, specified through the target="upload_target" in the form. Also, the forms onsubmit triggers the startUpload(); function.
Now we want to add some Javascript functions: Read More...
Note the ampersand (&) in front of the second variable, which is a variable pointer. This means that it takes in the address of the second variable and is able to edit the exact variable you passed to the function in real-time. So, if you pass an empty variable called $foo to it. The $foo variable will be an array with the results from the function. Why it doesnt just return an array is a mystery that'll remain unanswered, but I guess you could just call that PHP.
After reviewing some of my code, I found out I had been doing quite a lot of stuff in deprecated or just plain bad coding. The methods / functions described are PHP examples only.
Ternary Operator
Huh what does that do?!
$a = ($b >= 0) ? "b is positive" : "b is negative";
The basic markup of this 'method' is as follows:
$variable = (expression) ? "value if true" : "value if not";
So the example above would set $a to "b is positive" if ($b ?= 0) and would set it to "b is negative" if $b < 0.
So that means it's shorthand for:
if($b > 0)$a = "b is positive";
else$a = "b is negative";
Another way I've seen myself do something similar is explained by the following code:
$a = "b is negative";
if($b >= 0)$a = "b is positive"
Comparison operators
Everybody knows about using a double equals sign to compare two values. But have you ever heard of the triple-=? The triple equals-sign is to compare the values AND the types of the variables, cough:
Up until here, we've just initialized some variables. They kinda speak for themselves. $crap is merely some random nonsense to be displayed behind the actual text. Also, we've already registered the captcha string in the SESSION. Read More...