zero-perfoliate
zero-perfoliate

Author Topic: Problem in PHP File uploading  (Read 344 times)

Offline ED!T

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Problem in PHP File uploading
« on: November 11, 2009, 03:42:19 AM »
I have tried to upload a file using php. The code was 
-uploadfile.php-

<?php
if(isset($_POST['upload'])){
include("form_upload.inc");
}
else{
if($_FILES['pix']['temp_name']=="none"){
echo "Files didn't successfully uploaded.
";
include("form_upload.inc");
exit();
}
if(!ereg("image",$_FILE
S['pix']['type'])){
echo "File is not a picture
";
include("form_upload.inc");
exit();
}
else{
$destination="F:/Installed\/Xampp/xampp/htdocs/test/upload".$_FILES['pix']['name'];
$temp_file=$_FILES['pix']['name'];
move_uploaded_files($temp_file,$destination);
echo "<p> file uploaded successfully
{$_FILES['pix']['name']}
({$_FILES['pix']['size']})</p>";
}
}

?>

And I create an interface in an include file call 'form_upload.inc'

<html>
<head><title>File Upload</title></head>
<body>
<p>Enter the name of the picture</p>
<div align="center">
<form enctype="multypart/form-data"
action="uploadFile.php method=POST">
<input type="hidden" name="MAX_FILE_SIZE" value="500000">
<input type="file" name="pix" size="60">
<p><input type="submit" name="Upload"
value="Upload Picture">
</form>
</body>
</html>

interface is working but uploaded image is not at the particular destination, "F:/Installed\/Xampp/xampp/htdocs/test/upload".
I have set "upload_tmp_dir=" in php.ini to the destination address.

but when I upload "object not found" error occurred...

PLEASE HELP ME ......!!!!!!!!!!

Offline omkargupta

  • PHP Workers
  • **
  • Posts: 6
  • Karma: +0/-0
Re: Problem in PHP File uploading
« Reply #1 on: December 09, 2009, 10:21:54 PM »
hello dear
   
    try following code for file upload
   
move_uploaded_files($_files['upload']['tmp_name'],$destination)

for file upload