note 74580 rejected from features.file-upload by tularis
| From: | tularis@php.net | Date: | Wed, 18 Apr 2007 16:05:14 +0000 |
| Subject: | note 74580 rejected from features.file-upload by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125548@lists.php.net to get a copy of this message | ||
Note Submitter: wayne dot beck at carrier dot utc dot com
----
I am new to php so please go easy on me. I am using DW8 with PHP upload. I am able to upload my
files just fine. The problem I am having is adding a path link into my mysql database. here is my
code. This might not be the right location for this post. please point me in the correct
direction.
Thanks,
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "./uploaded_info");
define("no_error", "");
define("yes_error", "");
$_accepted_extensions_ = "";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
$_file_ = $HTTP_POST_FILES['upload_1'];
if(is_uploaded_file($_file_['tmp_name']) &&
$HTTP_POST_FILES['upload_1']['error'] == 0){
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
?>
<?php require_once('../Connections/tyler.php'); ?>
<?php
//Write the file name to the database
if (isset($upload_1)){
$HTTP_POST_VARS['upload1'] = $_name_;
$upload1 = $_name_;}
?>