Home » Source Code » Simple Upload File in PHP

Simple Upload File in PHP

faridblaster
2015-05-13 04:25:34
The author
View(s):
Download(s): 37
Point (s): 0 
Category Category:
EmbededEmbeded PHPPHP

Description

1. form - index.html


Send this file:


2. process - upload.php

<?php

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo "

"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; } else { echo "Upload failed"; } echo "

"; echo '
';
echo 'Here is some more debugging info:';
print_r($_FILES);
print "
";?>
3. viewContent.php

<?php
$dir = "/tmp";
$dh  = opendir($dir);
while (false !== ($filename = readdir($dh))) {
    $files[] = $filename;
}

sort($files);

print_r($files);

rsort($files);

print_r($files);

?>

5. advanced/view.php (nice view)





  

Directory Contents

<?php // Opens directory $myDirectory=opendir("."); // Gets each entry while($entryName=readdir($myDirectory)) { $dirArray[]=$entryName; } // Finds extensions of files function findexts ($filename) { $filename=strtolower($filename); $exts=split("[/\\.]", $filename); $n=count($exts)-1; $exts=$exts[$n]; return $exts; } // Closes directory closedir($myDirectory); // Counts elements in array $indexCount=count($dirArray); // Sorts files sort($dirArray); // Loops through the array of files for($index=0; $index < $indexCount; $index++) { // Allows ./?hidden to show hidden files if($_SERVER['QUERY_STRING']=="hidden") {$hide=""; $ahref="./"; $atext="Hide";} else {$hide="."; $ahref="./?hidden"; $atext="Show";} if(substr("$dirArray[$index]", 0, 1) != $hide) { // Gets File Names $name=$dirArray[$index]; $namehref=$dirArray[$index]; // Gets Extensions $extn=findexts($dirArray[$index]); // Gets file size $size=number_format(filesize($dirArray[$index])); // Gets Date Modified Data $modtime=date("M j Y g:i A", filemtime($dirArray[$index])); $timekey=date("YmdHis", filemtime($dirArray[$index])); // Prettifies File Types, add more to suit your needs. switch ($extn){ case "png": $extn="PNG Image"; break; case "jpg": $extn="JPEG Image"; break; case "svg": $extn="SVG Image"; break; case "gif": $extn="GIF Image"; break; case "ico": $extn="Windows Icon"; break; case "txt": $extn="Text File"; break; case "log": $extn="Log File"; break; case "htm": $extn="HTML File"; break; case "php": $extn="PHP Script"; break; case "js": $extn="Javascript"; break; case "css": $extn="Stylesheet"; break; case "pdf": $extn="PDF Document"; break; case "zip": $extn="ZIP Archive"; break; case "bak": $extn="Backup File"; break; default: $extn=strtoupper($extn)." File"; break; } // Separates directories if(is_dir($dirArray[$index])) { $extn="<Directory>"; $size="<Directory>"; $class="dir"; } else { $class="file"; } // Cleans up . and .. directories if($name=="."){$name=". (Current Directory)"; $extn="<System Dir>";} if($name==".."){$name=".. (Parent Directory)"; $extn="<System Dir>";} // Print 'em print(" "); } } ?>
Filename Type Size (bytes) Date Modified
$name $extn $size $modtime

<?php print("$atext hidden files"); ?>

Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
index.html252.00 B13-05-15 00:53
upload.php416.00 B13-05-15 00:54
<upload>0.00 B13-05-15 00:59
viewContent.php203.00 B13-05-15 00:58
style.css3.05 kB13-05-15 01:00
view.php4.05 kB13-05-15 00:59
<advanced>0.00 B13-05-15 01:00
...
Sponsored links

Comments

(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words
oa61398vx
2017-03-26

自己编的matlab调用c/c++例程代码,下来学习

ks613593a
2017-03-26

完整的MeanShift算法代码,谢谢楼主啦!

qa12126x4@sohu.com
2017-03-26

Tri-training算法程序,试一试,能用的

ky36174wr
2017-03-26

一次主动学习和半监督学习的多项算法源码,谢谢楼主啦!

og50404x4@sohu.com
2017-03-26

mpc预测控制算法matlab程序,感谢您的代码

kh88711nx
2017-03-26

很好用的最大后验概率(MAP)准则matlab开发程序,谢谢楼主啦!

qo44503r5
2017-03-26

我编写的自然梯度算法MATLAB编程,我也要学习

pv7926143@sohu.com
2017-03-26

一个AWGN信道Turbo码matlab开发代码,我也要学习

ml877449x
2017-03-26

真正的迭代算法ARTIIMATLAB编程,下来学习

xd26933a2@sohu.com
2017-03-26

测试过的光流法运动检测源例程,谢谢楼主啦!

tx79950vx
2017-03-26

课设的图像纹理特征算法,matlab编写,感谢您的代码

yw35918wr
2017-03-26

一个最大后验概率(MAP)准则源代码,谢谢楼主啦!

tx01006a@163.com
2017-03-26

调试成功的最大后验概率(MAP)准则完整程序,感谢您的代码

tn723392@126.com
2017-03-30

一个MeanShift算法,感谢您的代码

ii840230k
2017-03-30

课程作业时的流形学习算法matlab开发源码,感谢您的代码

so79565w@163.com
2017-03-30

全面的遗传算法做的作业调度问题完整程序,我也要学习

lv315880@139.com
2017-04-01
  1. form - index.html
tutu888
2017-07-19

很好用的最大后验概率(MAP)准则matlab开发程序,谢谢楼主啦!

yunyun87878700
2017-07-19

很好用的最大后验概率(MAP)准则matlab开发程序,谢谢楼主啦!

yunyun87878700
2017-07-19

自己编的matlab调用c/c++例程代码,下来学习

Simple Upload File in PHP (3.05 kB)

Need 0 Point(s)
Your Point (s)
Download Download

Download failed? Click here to download one by one.

Tip: this source code project contains 2 packages, please click the allow button on the browser pop-up dialog,after you click the download button.

▪ Click to download this source code directly

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D