Postby a1ever » Wed Jun 27, 2007 1:55 am

Posts: 1
Joined: Wed Jun 27, 2007 1:50 am
Hi..i would just like to ask..if i do not have a server but i'm just doing a project on PHP Scripts and so there is no server...and i wish to do the uploading file it possible because it seems that once user upload , the image will be stored in the server's temp folder yea..

Is it possible if once user browses to the location, then can do an update function where by the image is stored in the database instead, it gets updated into the database, because i also wanna do a view function where uploaded images can also be viewed by users so once having updated into the database, i can do a select statement to view all the datas inserted in the database?

Is it possible? Would appreciate greatly if someone could assist in the explanations for my query. Thank You!!!!


Postby tutorialspoint » Thu Jun 28, 2007 7:39 pm

Site Admin
Posts: 143
Joined: Fri Apr 27, 2007 6:52 pm
Hi Sheena!

You can upload any file any any directory. It depends what setting you have having in your .ini file.

So talk to your system administrator and he/she should be able to help you.

I won't suggest you to keep your images in database because it will slowdown your database and sooner or later you will be in performance problem. So store your images in any directory and then access them.

Even you are uploading your files in /tmp you can move them into any local directroy.

Hope this help
Moderator, TP
Keep visiting and share this site with your friends.


Postby ltward » Sun Mar 14, 2010 1:09 am

Posts: 1
Joined: Sun Mar 14, 2010 12:25 am
I couldn't get the sample script at ... oading.htm to work.
For one thing, there's a typo - it says "endtype" rather than "enctype".

However, this did work for me.

Code: Select all
<title>File Uploading Form</title>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form enctype="multipart/form-data" action="file_uploader.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="1000000">
  Upload this file <input name="userfile" type="file">
  <input type="submit" value="Upload File">

Code: Select all
if($_FILES['file']['error'] > 0)
  echo 'Problem: ';
  switch ($_FILES['file']['error'])
    case 1: echo 'File exceeded upload_max_filesize'; break;
    case 2: echo 'File exceeded max_file_size'; break;
    case 3: echo 'File only partially uploaded'; break;
    case 4: echo 'No file uploaded'; break;

$upfile = 'images/'.$_FILES['userfile']['name'];

if (is_uploaded_file($_FILES['userfile']['tmp_name']))
  if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile))
    echo 'Problem: Could not move file to destination directory';
  echo 'Problem: Possible file upload attack. Filename: ';
  echo $_FILES['userfile']['name'];

echo 'File uploaded successfully<br /><br />';


Hope that helps someone else out in the future.