Jump to content

easy upload


user4fun

Recommended Posts

awesome, it works, but the file get uploaded as a file not apicturethe ititred extension .gif to make it simple so I would work on the other extensions later and the picture url say.Website refuses to show picturereasonswebsite might need you to log in, or something to that effect?I dont ask people to log in? The upload is in the admin directory that is password protected, but after you gain acess why would it not work?

Link to comment
Share on other sites

awesome, it works, but the file get uploaded as a file not apicture...
A file is a file! So if you've uploaded a valid .gif file, then an html page can display that picture.
...the ititred extension .gif to make it simple so I would work on the other extensions later and the picture url say.Website refuses to show picturereasonswebsite might need you to log in, or something to that effect?I dont ask people to log in? The upload is in the admin directory that is password protected, but after you gain acess why would it not work?
Are you updating the html to use a new img src for the uploaded file, or what? You don't say what "refuses to show picture" means, for instance are you seeing an error message? If so, what is the message?Note that the tutorial includes how to copy the uploaded file to a different location. So you should be able to copy it to somewhere suitable for your html to reference it, not try and use it in the admin directory.
Link to comment
Share on other sites

the picks are being uploaded to listing/pics pulic directorythe uploading html form in is the directory /admin -this one is password protectedthe error is herehttp://zurielinvestment.com/listing/pics/test.gif
See what you mean. I get an http 403 error (forbidden) on test.gif and call_us.jpg, but I can view the other image files in that folder. Could be a file permissions thing--have you checked the permissions on these two files, to make sure they're the same as the ones that can be viewed?These 403 errors are generated for more than one reason. If it's not file permissions, try copying the file back from that folder to a local box, and check you can view it OK there, to make sure it's still a valid image file, and didn't get corrupted during your upload/copying process.
Link to comment
Share on other sites

well??I tired a few more times with different images and it is not working. here is the code jsut incase

<html><body><?//some stuff?>this file is in restircted access directory /admin<form action="upload_file.php" method="post"enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <br /><input type="submit" name="submit" value="Submit" /></form></body></html>

upload_file.php will upload the picture in directory ../listing/pics ( public directory)

<?phpif (($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/pjpeg")&& ($_FILES["file"]["size"] < 20000))  {  if ($_FILES["file"]["error"] > 0)	{	echo "Return Code: " . $_FILES["file"]["error"] . "<br />";	}  else	{	echo "Upload: " . $_FILES["file"]["name"] . "<br />";	echo "Type: " . $_FILES["file"]["type"] . "<br />";	echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";	echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";	if (file_exists("upload/" . $_FILES["file"]["name"]))	  {	  echo $_FILES["file"]["name"] . " already exists. ";	  }	else	  {	  move_uploaded_file($_FILES["file"]["tmp_name"],	  "../listing/pics/" . $_FILES["file"]["name"]);	  echo "Stored in: " . "../listing/pics/" . $_FILES["file"]["name"];	  }	}  }else  {  echo "Invalid file";  }?>

Link to comment
Share on other sites

This works great.chmod("../listing/pics/". $_FILES["file"]["name"], 0644);now i need rto make it all small letterstrtolower so i would have .gif not .GIF

For IE to recognize jpg files the type must be pjpeg, for FireFox it must be jpeg.
how would i make sure i go arround that and the right extension is replaced?it sounds complicated.
Link to comment
Share on other sites

For IE to recognize jpg files the type must be pjpeg, for FireFox it must be jpeg
That quote is referring to the MIME type, but you shouldn't need to worry about that unless one of the browsers is presenting you with a "download file" dialog.
Link to comment
Share on other sites

thank you, I am still trying to solve the strtolower problemThe files get uplaoded with an uppercase exstension. I think i have a syntax errori tired

$tmpe = $_FILES["file"]["tmp_name"];	 $filelink = strtolower($_FILES["file"]["name"]);	  move_uploaded_file $tmpe,"../listing/pics/",$filelink; //syntax error i believe	  chmod("../listing/pics/", $filelink, 0644);//or maybe it is here.

EDITEDGOT IT

 $filelink = strtolower ($_FILES["file"]["name"]);	 move_uploaded_file($_FILES["file"]["tmp_name"],	  "../listing/pics/".$filelink);	  echo "Stored in: " . "../listing/pics/" . $filelink;	  chmod("../listing/pics/". $filelink, 0644);

Thank you all, not i get to use $filelink to be the valued entered in my mysql table? YEAHH

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...