File Upload
I've got this small snippet for uploading an image, but it's not working. Anyone can help out? :)
I get an error that I've got the wrong file type when I try to post something.
<.h3>Zur Zeit im Studio - Neuer Eintrag
<.form action=" echo $PHP_SELF ?>" method="post" enctype="multipart/form-data">
<.table>
<.tr>
<.td>
<.b>Band:</b>
<.input type="text" name="band" size="40">
</td>
</tr>
<.tr>
<.td>
<.!-- this is where the image to upload goes-->
Bild URL:
<.input type="text" name="bild" size="40"></td>
</tr>
<.tr>
<.td>
Text:
<.textarea cols="50" rows="10" name="text"></textarea>
</td>
</tr>
<.tr>
<.td>
Englischer Text:
<.textarea cols="50" rows="10" name="entext"></textarea>
</td>
</tr>
<.tr>
<.td>
<.input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</form>
$GLOBALS['UPLOAD_SIZES']['max']){return -1;}
$arrSegments = split('[.]', $strName);
$strExtension = $arrSegments[count($arrSegments) - 1];
if ($GLOBALS['UPLOAD_TYPES'][strtoupper($st rExtension)] != 1) {return -2;}
return 1;}
$intResult = verify_uploaded_file(
$HTTP_POST_FILES['upload_file']['name'],
$HTTP_POST_FILES['upload_file']['size']) ;
if ($intResult != 1){
print ("
elseif ($intResult == -2){die($msg_base . 'The only file types allowed are: JPG, JPEG, GIF, PNG.</p>');}
}if (! move_uploaded_file($HTTP_POST_FILES['upl oad_file']['tmp_name'],
$MOVE_TO_PATH . $HTTP_POST_FILES['upload_file']['name']) ){die('You did not upload a file or the file could not be moved to ' . $MOVE_TO_PATH . $HTTP_POST_FILES['upload_file']['name']) ;}
*/
$sql = "INSERT INTO table(timestamp,band,bild,text,entext) VALUES ('$timestamp','$band','$bild','$text','$e ntext')";
$result = mysql_query($sql) or print ("Can't insert into table .
" . $sql . "
" . mysql_error());
if ($result != false)
{
print "Die Band wurde gepostet!";
}
mysql_close();
}
?>
I get an error that I've got the wrong file type when I try to post something.
<.h3>Zur Zeit im Studio - Neuer Eintrag
<.form action=" echo $PHP_SELF ?>" method="post" enctype="multipart/form-data">
<.table>
<.tr>
<.td>
<.b>Band:</b>
<.input type="text" name="band" size="40">
</td>
</tr>
<.tr>
<.td>
<.!-- this is where the image to upload goes-->
Bild URL:
<.input type="text" name="bild" size="40"></td>
</tr>
<.tr>
<.td>
Text:
<.textarea cols="50" rows="10" name="text"></textarea>
</td>
</tr>
<.tr>
<.td>
Englischer Text:
<.textarea cols="50" rows="10" name="entext"></textarea>
</td>
</tr>
<.tr>
<.td>
<.input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</form>
$GLOBALS['UPLOAD_SIZES']['max']){return -1;}
$arrSegments = split('[.]', $strName);
$strExtension = $arrSegments[count($arrSegments) - 1];
if ($GLOBALS['UPLOAD_TYPES'][strtoupper($st
return 1;}
$intResult = verify_uploaded_file(
$HTTP_POST_FILES['upload_file']['name'],
$HTTP_POST_FILES['upload_file']['size'])
if ($intResult != 1){
print ("
Error!");
if ($intResult == -1){die ($msg_base . 'The button is too large.
elseif ($intResult == -2){die($msg_base . 'The only file types allowed are: JPG, JPEG, GIF, PNG.</p>');}
}if (! move_uploaded_file($HTTP_POST_FILES['upl
$MOVE_TO_PATH . $HTTP_POST_FILES['upload_file']['name'])
*/
$sql = "INSERT INTO table(timestamp,band,bild,text,entext) VALUES ('$timestamp','$band','$bild','$text','$e
$result = mysql_query($sql) or print ("Can't insert into table .
" . $sql . "
" . mysql_error());
if ($result != false)
{
print "Die Band wurde gepostet!";
}
mysql_close();
}
?>
