August 4, 2013

Getting error in uploading file in php

CAO’s Question:

I am trying to create a upload form through which the user can enter certain details(including a file upload) and then it will be inserted into a database, the row is entered successfully but I get this error. i.e
Warning: move_uploaded_file(upload/computer/SIGN 001.jpg): failed to open stream: No such file or directory in C:wampwwwstockm.php on line 28
&
Warning: move_uploaded_file(): Unable to move ‘C:wamptmpphp2CEE.tmp’ to ‘upload/computer/SIGN 001.jpg’ in C:wampwwwstockm.php on line 28

this is the code which has the entire scripting for the upload file portion.

$name= $_FILES['file']['name'];
  $tmp_name = $_FILES['file']['tmp_name']; 
  $type = $_FILES['file']['type']; 
  $size = $_FILES['file']['size'];
  $pathAndName = "upload/computer/".$name;
  $moveResult = move_uploaded_file($tmp_name, $pathAndName);

I have created a folder in C:/wamp/upload named computer where I want the image to be sent, in the database I get this location but in upload/computer there is no file, the folder is empty.

Your path $pathAndName = "upload/computer/".$name; is a relative path, thus it will search from the current directory of the executing script.

For example, if you are running from wampwwwtestupload.php it will search for wampwwwtestuploadcomputer path.

You can assign the path from the root directory as "/upload/computer/".$name;, this will search for wampwwwuploadcomputer path.

Further more, you have to check if the folder exist in the path and it has permission to access it or read it.

June 4, 2010

Is using AMP software like WAMP, MAMP, XAMPP a good idea?

Question by Starx

I know that softwares like WAMP, XAMPP save a lot of difficult configuration time. But, besides this, Is this a good idea? I, on the other would like to stick to traditional method and install each component seperately and use them.

Answer by Starx

Of course it’s a good idea. Easy configuration means, saved time. Saved time means, projects complete fast. Fast completion of projects means more projects and More projects mean more money. 🙂 lol

...

Please fill the form - I will response as fast as I can!