My uploads are just not working!

could you help with a simple example?

Page 1 of 1

7 Replies - 479 Views - Last Post: 04 October 2009 - 01:09 AM Rate Topic: -----

#1 coolmac112  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 30-August 09

My uploads are just not working!

Posted 01 October 2009 - 10:28 PM

Hi guys,

I am a newbie at php, and it seems i just cant upload and move a simple file...i have tried everything under the sun, believe me, but still...same result.

Could you give me a simplified script of uploading and moving the file?...I want a fresh start.

Thanks
Is This A Good Question/Topic? 0
  • +

Replies To: My uploads are just not working!

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: My uploads are just not working!

Posted 01 October 2009 - 10:52 PM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 coolmac112  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 30-August 09

Re: My uploads are just not working!

Posted 02 October 2009 - 12:14 AM

I could see that one coming! I knew someone would think i'm a lazyass! lol!

Anyway I just wanted a real fresh start...

The code I have been using is this:

<form action="uploader.php" method="post" enctype="multipart/form-data">
<label for="name">Name:</label>
<input type="text" name="name" id="name" /><br />
<input type="hidden" value="32768" name="MAX_FILE_SIZE" />
<input type="file" name="filex" id="screenshot" /><br />
<input type="submit" value="submit" name="submit" />
</form>


Okay thats the html form...for the uploader.php
<?php
//this is where the files are going to be uploaded to
$target = "uploads/";
echo $_FILES["filex"]["name"]."<br />";

if($_FILES["filex"]["error"] > 0){
	echo "File could not be uploaded".$_FILES["filex"]["error"];
}

if(move_uploaded_file($_FILES["filex"]["temp_name"],$target.$_FILES["filex"]["name"])){
	echo "file moved";
}
else{
	echo "was not moved!<br />";
}
if(is_dir("uploads")){
	echo "it is a folder!<br />";
}
if(is_writable("uploads")){
	echo "but it is writable <br />";
}
?>


it is indeed returning the filename, and confirming that uploads is a directory that is also writeable. but sadly it is also returning "was nor moved!"

what could i be doing wrong here?

This post has been edited by coolmac112: 02 October 2009 - 12:15 AM

Was This Post Helpful? 0
  • +
  • -

#4 coolmac112  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 30-August 09

Re: My uploads are just not working!

Posted 03 October 2009 - 10:46 PM

help! someone
Was This Post Helpful? 0
  • +
  • -

#5 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: My uploads are just not working!

Posted 03 October 2009 - 11:05 PM

check out this --->> http://www.w3schools...file_upload.asp
Was This Post Helpful? 1
  • +
  • -

#6 coolmac112  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 30-August 09

Re: My uploads are just not working!

Posted 04 October 2009 - 12:53 AM

Thanks very much snowflakes.

I followed the instructions and its printing the values of all the $_FILES array ...like

$_FILES["uploaded_file"]["name"]
$_FILES["uploaded_file"]["type"]
$_FILES["uploaded_file"]["size"]

surprisingly $_FILES["uploaded_file"]["temp_name"] is blank..I'm convinced that is where the problem is coming from..is the file not being stored even in the temporary folder?

I checked my php.ini and this is my setting for temp:

upload_tmp_dir = "C:\xampp\tmp"

I'm running xampp btw.
Was This Post Helpful? 0
  • +
  • -

#7 coolmac112  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 30-August 09

Re: My uploads are just not working!

Posted 04 October 2009 - 01:00 AM

I just fixed that one...it was a typo...was supposed to be tmp_name not temp_name like what I had done...now to the next step!
Was This Post Helpful? 0
  • +
  • -

#8 coolmac112  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 30-August 09

Re: My uploads are just not working!

Posted 04 October 2009 - 01:09 AM

PROBLEM SOLVED GUYS! Thank you so much Snowflakes and everyone else who chipped in!

Thank you!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1