As pointed out previously, you need to turn on error reporting. Edit php.ini to set this up. All the information you need is found at php.net, in this case php.ini directives. If you have several php.ini files in different places and don't know which is being used, you can run a php script containing simply
phpinfo();
and it will tell you the location of php.ini, among lots of other things.
You need to specify what errors should be reported, such as
error_reporting = E_ALL
In a development environment, you will most likely want
# php version >= 5.2.4
display_errors = std_err
# php < 5.2.4
display_errors = 1
# file to be used for logging errors. The web server user must have write access for
# this to work
error_log = /path/to/logfile
# enable logging
log_errors = 1
In a production environment, you should definitely turn off displaying errors. I.e. display_errors = 0
leatherback;10984971 wrote:
print_r($FILES);
print_r($POST);
on top of your script, and see what that gives you (View source is usually best).
I prefer using
printf('<pre>%s</pre>', print_r($_POST,1));
# and corresponding code for any other array I need to inspect
Since the pre element preserves whitespaces, which means the array is displayed with indented output right in the web page.
As for this part
$image = $_POST["image"]["name"];
$video = $_POST["video"]["name"];
With error reporting turned on, you'd get errors for both these lines. Perhaps they should be $_FILES[...][...].
According to the documentation of [man]move_uploaded_file[/man], the second parameter is the destination file, while you provide a directory. I'm just guessing, but I believe the OS won't allow you to overwrite a directory with a file, and move_uploaded_file will overwrite the destination if it exists, so you will probably get errors here as well.
Also, you do not check if the move was successful, so you have no idea if the files are actually saved in a permanent location.
$dir = '../media/videos/';
# Creates a new file, automatically generating a unique filename for this directory
$filename = tempnam($dir);
if (!move_uploaded_file($_FILES['video']['tmp_name'], $dir.$filename))
{
# Failure
# Don't store information in the database since the file hasn't been saved.
# Inform the user that the upload has failed.
}
else
{
# Success
}
The same goes for the execution of your sql query. You have no idea if it succeeded
$result = mysql_query();
if (!$result)
{
# error
# You should probably remove the recently saved file(s) since you won't be able
# to find a corresponding entry in the db later on.
# Obviously, also inform the user that the upload failed.
}
Part 14.30 of the HTTP 1.1 specification states that
The field value consists of a single absolute URI.
Location = "Location" ":" absoluteURI
An example is:
Location: [url]http://www.w3.org/pub/WWW/People.html[/url]
This means that what you have,
header('Location: success.php');
is incorrect and has to be 'Location: http://example.com/success.php'. And you should obviously only perform a redirect to success.php if the file uploads, including database inserts, were successful.