Jump to content

Recommended Posts

I'm attempting to get a file upload script to work within PHP-Fusion. Unfortunately I can't actually get the file uploaded:

 

} elseif ($_GET['stype'] == "d") {
if (isset($_POST['submit_download'])) {
	if ($_POST['download_name'] != "" && $_POST['imagefile'] != "") {
		copy ($_FILES['imagefile']['tmp_name'], "/downloads/".$_FILES['imagefile']['download_name']); 
		$download_cat = stripinput($_POST['download_category']);
		$download_title = stripinput($_POST['download_name']);
		$download_url = "/downloads/".$_FILES['imagefile']['download_name']."";
		$result = dbquery("INSERT INTO ".DB_DOWNLOADS." (download_title, download_url, download_cat, download_datestamp, download_count) VALUES ('$download_title', '$download_url', '$download_cat', '".time()."', '0')");
		add_to_title($locale['global_200'].$locale['700']);
		opentable($locale['700']);
		echo "<div style='text-align:center'><br />\n".$locale['705']."<br /><br />\n";
		echo "<a href='submit.php?stype=d'>".$locale['706']."</a><br /><br />\n";
		echo "<a href='index.php'>".$locale['412']."</a><br /><br />\n</div>\n";
		closetable();
	}
} else {
	$opts = "";
	add_to_title($locale['global_200'].$locale['700']);
	opentable($locale['700']);
	$result = dbquery("SELECT * FROM ".DB_DOWNLOAD_CATS." WHERE ".groupaccess("download_cat_access")." ORDER BY download_cat_name");
	if (dbrows($result)) {
		while ($data = dbarray($result)) {
			$opts .= "<option value='".$data['download_cat_id']."'>".$data['download_cat_name']."</option>\n";
		}
		echo $locale['420']."<br /><br />\n";
		echo "<form name='submit_form' method='post' action='".FUSION_SELF."?stype=d' onsubmit='return validateLink(this);'>\n";
		echo "<table cellpadding='0' cellspacing='0' class='center'>\n";
		echo "<tr>\n<td class='tbl'>".$locale['701']."</td>\n";
		echo "<td class='tbl'><select name='download_category' class='textbox'>\n$opts</select></td>\n";
		echo "</tr>\n<tr>\n";
		echo "<td class='tbl'>".$locale['702']."</td>\n";
		echo "<td class='tbl'><input type='text' name='download_name' maxlength='100' class='textbox' style='width:300px;' /></td>\n";
		echo "</tr>\n<tr>\n";
		echo "<td class='tbl'>".$locale['704']."</td>\n";
		echo "<td class='tbl'><input type='text' name='download_version' maxlength='100' class='textbox' style='width:300px;' /></td>\n";
		echo "</tr>\n<tr>\n";
		echo "<td class='tbl'>".$locale['703']."</td>\n";
		echo "<td class='tbl'><input type='file' name='imagefile' class='textbox' style='width:300px;'></td>\n";
		echo "</tr>\n<tr>\n";
		echo "<td align='center' colspan='2' class='tbl'><br />\n";
		echo "<input type='submit' name='submit_download' value='".$locale['700']."' class='button' />\n</td>\n";
		echo "</tr>\n</table>\n</form>\n";
	} else {
		echo "<div style='text-align:center'><br />\n".$locale['551']."<br /><br />\n</div>\n";
	}
	closetable();
}
}

 

I get the following error after I submit the form:

 

Notice: Undefined index: imagefile in /home/troop1/public_html/submit.php on line 139

 

Notice: Undefined index: imagefile in /home/troop1/public_html/submit.php on line 139

 

Warning: copy() [function.copy]: Filename cannot be empty in /home/troop1/public_html/submit.php on line 139

 

Notice: Undefined index: imagefile in /home/troop1/public_html/submit.php on line 142

 

Can anyone help me out with this?

Link to comment
https://forums.phpfreaks.com/topic/181628-php-fusion-upload-script/
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.