List Info

Thread: note 74580 added to features.file-upload




note 74580 added to features.file-upload
user name
2007-04-18 07:44:49
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_;}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 192.249.47.11
----
Manual Page -- http://www.php.net/manual/en/features.file-upload.php
Edit        -- https://master
.php.net/note/edit/74580
Del: integrated  -- h
ttps://master.php.net/note/delete/74580/integrated
Del: useless     -- http
s://master.php.net/note/delete/74580/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/74580/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/74580/spam
Del: non-english -- 
https://master.php.net/note/delete/74580/non-english
Del: in docs     -- http
s://master.php.net/note/delete/74580/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74580
Reject      -- https://mast
er.php.net/note/reject/74580
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )