Jump to content


Photo

file upload script help!!


  • Please log in to reply
12 replies to this topic

#1 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 06:09 PM

I can't figure out how to get this to upload to the server
and then if its possible a thumbnail of the pic under that

<form name="form1" method="post" action="" enctype="multipart/form-data"> 
<input type="file" name="imagefile"> 
<br><input type="submit" name="Submit" value="Submit"> 
<br>&nbsp; 
<?php 
if(isset($Submit)){ 
  $file=$_FILES['imagefile']['name']; 
  $filetype=substr($file,-4); 
  if($filetype=="jpeg"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }elseif($filetype==".jpg"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }elseif($filetype==".png"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }elseif($filetype==".gif"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }else{ 
    echo"<br><span class="subtitle">Upload Error</span>"; 
    echo"<br>Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>"; 
  } 
} 
?> 
</form>
pleeze help!

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 23 August 2006 - 06:22 PM

You cannot use $Submit unless globals are turned on, which they are not by default you have to use $_POST['Submit']

Ray

#3 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 06:28 PM

where do i put that ???

#4 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 23 August 2006 - 06:30 PM

replace '$Submit' in your script with '$_POST['Submit']'
What is the CoronaMatrix?

#5 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 06:36 PM

where would i put the script to upload it to the database?
and if possible make a thumb nail of it?

#6 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 06:41 PM

Warning: copy(images/BEN.png) [function.copy]: failed to open stream: No such file or directory in /home/pokebash/public_html/pic_upload.php on line 24
Could not copy
that was the error message i just got what should i do to fix it.
<form name="form1" method="post" action="" enctype="multipart/form-data"> 
<input type="file" name="imagefile"> 
<br><input type="submit" name="Submit" value="Submit"> 
<br>&nbsp; 
<?php 
if(isset($_POST['Submit'])){ 
  $file=$_FILES['imagefile']['name']; 
  $filetype=substr($file,-4); 
  if($filetype=="jpeg"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }elseif($filetype==".jpg"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }elseif($filetype==".png"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }elseif($filetype==".gif"){ 
    copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) 
    or die("Could not copy"); 
    echo"<br>Upload Complete"; 
    echo"<br>Name:&nbsp;".$_FILES['imagefile']['name'].""; 
    echo"<br>Size:&nbsp;".$_FILES['imagefile']['size'].""; 
    echo"<br>Type:&nbsp;".$_FILES['imagefile']['type']."<br>"; 
  }else{ 
    echo"<br><span class=\"subtitle\">Upload Error</span>"; 
    echo"<br>Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>"; 
  } 
} 
?> 
</form>


#7 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 23 August 2006 - 06:48 PM

That means it can't find the directory

try using the absolute path instead

replace these lines
copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name'])

with this
copy($_FILES['imagefile']['tmp_name'],"/home/pokebash/public_html/images/".$_FILES['imagefile']['name'])

Ray

#8 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 06:51 PM

thanks but i figuered out what i did wrong i didn't make a folder called images!!
really stupid mistake.

#9 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 06:55 PM

now that ive figuered that out instaed of making a a boring directary page where the pics are stored is possible to make a page that the pics can go to ???

#10 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 23 August 2006 - 07:25 PM

Yes look up on how to read a directory then lookup the gdlib functions to create thumbnails for the pics.

Can't do everything for ya my man

Ray

#11 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 23 August 2006 - 07:25 PM

Thanks for the help people!!

:D

#12 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 23 August 2006 - 07:28 PM

If you feel like looking at some code ... look at phpWebAlbum (google it) and check it out.  It uses gd to manipulate images.
What is the CoronaMatrix?

#13 litebearer

litebearer
  • Members
  • PipPipPip
  • Advanced Member
  • 2,357 posts
  • Locationwhite lake michigan

Posted 23 August 2006 - 09:46 PM

Might also look here. With a little tweaking you can have it do what you want.

(be sure to see the example)

http://www.nstoia.co...stdir/index.php

Lite...

all the brothers were valiant!

[br][br]The truely intelligent people are not those who create the dots; rather they are they ones with the ability to connect the dots into a coherent picture




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users