Jump to content

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

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.