Jump to content

Recommended Posts

My code is pulled out of another form and im trying to get it to upload a pdf

There are some errors with the " " in the $content .= part.

 

<?PHP
if(isset($_GET['action']))
{
    $action=addslashes($_GET['action']);
}

$content .=	'<form enctype=\"multipart/form-data\" action=\"?action=douploadn\" method=\"POST\">
Upload Newsletter<br>
<p>
<label>File:</label><input type=\"file\" name=\"newsletter\" size=\"15\">
</p>
<p>
<label></label><input type=\"Submit\" value=\"Upload\">
</form>';

if ($action == "douploadn") {

$filetype = $_FILES['newsletter']['type'];

if($filetype == "application/pdf") {

  $target_path = "newsletter/";
  $target_path = $target_path . basename( $_FILES['newsletter']['name']); 
  if(move_uploaded_file($_FILES['newsletter']['tmp_name'], $target_path)) { $ok = "The file has been uploaded!"; } else { $ok = "There was an error when uploading the file!"; }

  $fn=basename( $_FILES['newsletter']['name']); 

  echo "<center>$ok<br>You can see the file here: <a href=\"newsletter/".basename( $_FILES['newsletter']['name'])."\">".basename( $_FILES['newsletter']['name'])."</a>";

  mysql_query("UPDATE newsletter SET newsname='$fn' WHERE newsid='1'");

} else {

  Header("Location: index.php?action=wrongtype");

}

} 
	?>

 

any  help be great

 

Link to comment
https://forums.phpfreaks.com/topic/140240-solved-few-little-errors/
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.