Permalink
Browse files

error in call unknown function

  • Loading branch information...
1 parent a3ff94b commit 4e1a63dfcef40727acd1f108cf08813a59af6c7b @ali-khabbaz committed May 4, 2012
Showing with 72 additions and 0 deletions.
  1. +14 −0 my-[php] file upload/index.html
  2. +58 −0 my-[php] file upload/upload.php
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>Oontitled Document</title>
+</head>
+<body>
+<h1>Upload Form</h1>
+<form action="upload.php" method="post" enctype="multipart/form-data" >
+ <input type="file" name="myfile" />
+ <input type="submit" value="Upload" />
+</form>
+</body>
+</html>
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8" />
+<title>Oontitled Document</title>
+</head>
+<body>
+
+<div class="uploaded">
+<?php
+
+function upload_img($dir_path, $size_limit){
+
+ $file = $_FILES['myfile'];
+ $size_limit *=1024; // to KB
+
+ if( $file['error'] !== 0 ){
+ echo 'Error in uploading.';
+ return false;
+ }
+
+ if( substr($file['type'],0,5) != 'image' ){
+ echo 'Error in file type.';
+ return false;
+ }
+
+ if( $file['size'] > $size_limit ){
+ echo 'Error in file size.';
+ return false;
+ }
+
+ $file_path = "$dir_path/$file[name]"; // "" baraye name dige lazem nist chon kolan too "" hastesh
+ move_uploaded_file ($file['tmp_name'], $file_path);
+
+ return $file_path;
+}
+
+$img = upload_img('./uploaded',200); //call upload_img and need to creat new folde by name uploaded
+
+if($img) echo "Path : $img <br /> <img src='$img' width='300' />";
+
+
+?>
+</div>
+
+
+
+<pre>
+
+
+
+<?php
+ print_r($_FILES);
+?>
+</pre>
+
+</body>
+</html>

0 comments on commit 4e1a63d

Please sign in to comment.