Joey46 Posted October 1, 2008 Share Posted October 1, 2008 "PHP CODE"<? if ((($_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 "Error: " . $_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 "Stored in: " . $_FILES["file"]["tmp_name"]; } }else { echo "Invalid file"; }?>"HTML CODE"<h1><span class="style1">Upload</span></h1><form method="post" enctype="multipart/form-data" action="upload.php"><input type="hidden" name="MAX_FILE_SIZE" value="1000000" /><table width="350" border="0" cellpadding="1" cellspacing="1" class="box"><tr> <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="1000000"><input name="file" type="file" id="imagefile">. Link to comment Share on other sites More sharing options...
jeffman Posted October 1, 2008 Share Posted October 1, 2008 Use move_uploaded_file() to store the temporary file in a directory of your choice and give it a meaningful name. This makes it a permanent file. Now the script or HTML document that needs to display the image can do so in the usual way. (Whatever usual means to you.)For instance, if every user has one unique image, then you can store the username and the image path together in a database or flat file. When the user logs in, your script gets the image path and echoes that into the user's welcome page. (Again, that's just an example.) Link to comment Share on other sites More sharing options...
Joey46 Posted October 1, 2008 Author Share Posted October 1, 2008 Use move_uploaded_file() to store the temporary file in a directory of your choice and give it a meaningful name. This makes it a permanent file. Now the script or HTML document that needs to display the image can do so in the usual way. (Whatever usual means to you.)For instance, if every user has one unique image, then you can store the username and the image path together in a database or flat file. When the user logs in, your script gets the image path and echoes that into the user's welcome page. (Again, that's just an example.)it doesn't work means it is going into a folder instead of going into the gallery page everything else works except that and thank you for your help Link to comment Share on other sites More sharing options...
justsomeguy Posted October 1, 2008 Share Posted October 1, 2008 How does your gallery display images? Where do they come from? Can't you update the gallery to point to the new images?You don't upload pictures to a web page, you upload them to a web server. The web server stores them in a temporary directory (which they get deleted from if you don't move them), and PHP includes a function to move an uploaded file like Dad mentioned. A web page just contains an image tag to show an image, with the address of the image in the tag. It's sort of up to you to figure out how your gallery shows images (are the filenames in a database? does it look in a particular folder? is it just a static HTML page?) and set it up so that it shows the new images that were uploaded. We can't do that for you. Link to comment Share on other sites More sharing options...
Joey46 Posted October 1, 2008 Author Share Posted October 1, 2008 How does your gallery display images? Where do they come from? Can't you update the gallery to point to the new images?You don't upload pictures to a web page, you upload them to a web server. The web server stores them in a temporary directory (which they get deleted from if you don't move them), and PHP includes a function to move an uploaded file like Dad mentioned. A web page just contains an image tag to show an image, with the address of the image in the tag. It's sort of up to you to figure out how your gallery shows images (are the filenames in a database? does it look in a particular folder? is it just a static HTML page?) and set it up so that it shows the new images that were uploaded. We can't do that for you.Hi there,yes it is just a static page do you have any suggestions on how to change the page from static to show the images as i am only new to php and atm it is sending me bonkers trying to work it outthank you for your imput Link to comment Share on other sites More sharing options...
justsomeguy Posted October 2, 2008 Share Posted October 2, 2008 Are all of the images to show in the same folder? It would be easy enough to make a script that gets a list of files in a folder and writes them out into image tags. The upload script could also move the new files into that same folder so that the gallery would automatically pick them up the next time it was loaded. If the images are scattered in several locations then you could set up a text file where PHP could read the filenames and write out the HTML code. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.