Jump to content

uploading error


doddsey_65

Recommended Posts

the following is a script that is already in use for a different part of my site to upload a profile picture to a directory and then send the path of it to the database. Hoever i have copied the script and tried to use it in a different way. Same premise but a bit more information being sent with it. When I click upload it says there was an error uploading. Is this because i have done something wrong? or is it because i am inserting info into the database and sending the file to the directory?

 

<?php

ob_start();

$uploadDir2 = 'tutcovers/';

if(isset($_POST['upload_btn3']))
{
$fileName2 = $_FILES['userfile3']['name'];
$tmpName2 = $_FILES['userfile3']['tmp_name'];

$filePath2 = $uploadDir2 . $fileName2;

$result = move_uploaded_file($tmpName2, $filePath2);
if (!$result) {
echo "Error uploading file";
exit;
}

if(!get_magic_quotes_gpc())
{
$filePath2 = addslashes($filePath2);
} 

$sql = ("INSERT INTO tutorials (name, description, username, fullname, link, path, category, length) 
VALUES ('".$_POST['name']."', '".$_POST['description']."', '".$_POST['username']."', '".$_POST['fullname']."', '".$_POST['embedd']."', '".$filepath2."', '".$_POST['category']."', '".$_POST['vidlength']."')");
$result = mysql_query($sql, $db);

}
echo '

<div id="page">
	<div id="content">
	  <div class="post">
<p class="meta">Your image has been successfully uploaded</p>
			<div class="entry">';
echo 'Your tutorial has been successfully uploaded. Click <a href=myaccount.php>here</a> to go back.
</div></div></div>';
include('footer.php');


ob_flush(); 
?>

Link to comment
https://forums.phpfreaks.com/topic/197701-uploading-error/
Share on other sites

$filepath2 has been set :

$filePath2 = $uploadDir2 . $fileName2;

 

I have kept everything the same as is in the other upload script i am using(in which everything works) the only difference is that the one that works only uploads an image to the server and sends the path to the database while with this one I am trying to add some field information aswell as the image.

Link to comment
https://forums.phpfreaks.com/topic/197701-uploading-error/#findComment-1040162
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.