Upload problem with my php form... Please help!

Status
Not open for further replies.

uplinked

Member
Messages
75
Reaction score
1
Points
8
Hi

Are uploads through a php form on by default? I have a new database and a new user with all the priviledges granted. The database connection works great...

However, I cannot upload any files through the php form... The failure I get is a query which does not execute...

Is it my code or are the uploads restricted?

Kindly take a look at: http://www.uplinked.x10hosting.com/upload_video.php

I post the code gladly if someone wants to take a look at it...

Tkankful for reply. :happysad:
 

selcane

New Member
Messages
17
Reaction score
0
Points
0
if you go to the cpanel home, and go to anonymous ftp and check the Allow anonymous uploads to...box, then your uploads should go to the public_ftp/incoming directory...

i havnt looked at ur code though
selcan
 

compwhizii

Banned
Messages
779
Reaction score
0
Points
0
if you go to the cpanel home, and go to anonymous ftp and check the Allow anonymous uploads to...box, then your uploads should go to the public_ftp/incoming directory...

i havnt looked at ur code though
selcan

So posting a random guess helps how?
 

uplinked

Member
Messages
75
Reaction score
1
Points
8
Can I see the error you get?


Sure... Here you go:


<?php
$page_title = 'Ladda upp video';

//Kontrollera titeln
if (!isset($page_title)) {
$page_title = 'Media rummet';
}

//Filuppladdning

if (isset($_POST['submit'])) {

//Uppkoppling
define ('DB_USER', 'uplinked_every1');
define ('DB_PASSWORD', 'free');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'uplinked_mov');

$dbc = mysql_connect ('localhost', 'uplinked_every1', 'free') or die(mysql_error());

mysql_select_db ('uplinked_mov');

$dbs = @mysql_list_dbs($dbc) or die(mysql_error());

if ($dbc) { $msg = "Databasuppkopplingen &auml;r uppr&auml;ttad..."; }

//Escaping form data
function escape_data ($data) {
global $dbc;
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string (trim($data), $dbc);
}

//Testa for tom beskrivning samt skala
if (!empty($_POST['description'])) {
$d = escape_data($_POST['description']);
} else {
$d = '';
}

//Lagg till videon i databasen
$query = "INSERT INTO video_uploads (file_name, description, upload_date) VALUES ('{$_FILES['upload']['name']}', '$d', NOW())";
$result = @mysql_query ($query);

if ($result) { //Create filename
$extension = explode ('.', $_FILES['upload']['name']);
$uid = mysql_insert_id(); //Upload ID
$filename = $uid . '.' . $extension[1];

//move the file
if (move_uploaded_file($_FILES['upload']['tmp_name'], "../video_uploads/$filename")) {
echo '<p>Filen laddades upp!</p>';
} else {
echo '<p><font color="red">Filen kan inte flyttas! F&ouml;rs&ouml;k igen!</font></p>';
$query = "DELETE FROM video_uploads WHERE upload_id = $uid";
$result = @mysql_query ($query);
}
} else { //if the query failed
echo '<p><font color="red">Filen kunde inte laddas upp p&aring; grund av ett tekniskt fel. Var god f&ouml;rs&ouml;k senare!</font></p>';

}

mysql_close();
}

include_once ('multimedia_division/header.html');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sv" lang="sv">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title><?php echo $page_title; ?></title>

</head>

<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<fieldset><legend>Ladda upp video</legend>
<input type="hidden" name="MAX_FILE_SIZE" value="60000" />
<p>Mediafil att ladda upp:<br />
<input type="file" name="upload" /></p>
<p>Beskrivning:<br /><input type="text" name="description" size="35" maxlength="500" /></p>
<p><input type="submit" name="submit" value="Ladda upp" /></p>
</fieldset>
</form>

<p><font color="#50a8de"><?php echo "$msg"; ?></font></p>

</body>
</html>

<?php
include_once ('multimedia_division/footer.html');
?>


As you might guess, the query fails *see green code*. It might be something else too... Thanks for looking at it! :biggrin:
Edit:
if you go to the cpanel home, and go to anonymous ftp and check the Allow anonymous uploads to...box, then your uploads should go to the public_ftp/incoming directory...

i havnt looked at ur code though
selcan

I just posted the code here... anonymous uploading should work through my database and http... I am not using ftp so I don't think this helps me out right now...

Thanks anyway!
 
Last edited:

selcane

New Member
Messages
17
Reaction score
0
Points
0
i'm new to php, so i dont mean to insult you because you are obviously not new to php, but the following debug code may help,
also...just out of curiosity, why do you have an @ in front of the query??

// Perform Query
$result = mysql_query($query);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}

you can check my answer in the other thread as well....
 

uplinked

Member
Messages
75
Reaction score
1
Points
8
Oh dear... that was a good idea. =)

I will remove the @ (which suppresses the error message and prints what I specify as error) and get back to you with more details about the error I get...

I am building this page to upload files to a specific folder, through the temp directory, Selcane.

-------------------------------------------------

I now return with news after I checked my code without the @... No changes. The quiery fails and I do not get any specific reason. I will check the code again...

Anyone who has a good suggestion is welcome to comment this... =)

So long...

//uplinked.
 
Last edited:
Status
Not open for further replies.
Top