kentopolis Posted March 2, 2007 Share Posted March 2, 2007 Hi all, I have this script for uploading images from a computer, but I need to be able to upload using URL's as well, here is the portion of the script I think needs to change, if you need more let me know... Thanks for your help, I am quite a newbie at PHP... }elseif($_POST['upload']){ $page = $_POST['page']; if ($_FILES['imagefile']['type'] == "image/pjpeg" || $_FILES['imagefile']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile']['tmp_name'], "uploads/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile']['name'].")"; } /////////////////////////////// }elseif($_POST['upload2']){ $page = $_POST['page']; if ($_FILES['imagefile2']['type'] == "image/pjpeg" || $_FILES['imagefile2']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile2']['tmp_name'], "uploads/a/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile2']['name'].")"; }/////////////////////////////// }elseif($_POST['upload3']){ $page = $_POST['page']; if ($_FILES['imagefile3']['type'] == "image/pjpeg" || $_FILES['imagefile3']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile3']['tmp_name'], "uploads/b/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile3']['name'].")"; }//////////////////////////////////// }elseif($_POST['upload4']){ $page = $_POST['page']; if ($_FILES['imagefile4']['type'] == "image/pjpeg" || $_FILES['imagefile4']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile4']['tmp_name'], "uploads/c/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile4']['name'].")"; } Quote Link to comment https://forums.phpfreaks.com/topic/40888-uploading-from-url-computer/ Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 Dont get the quistion sorry? Quote Link to comment https://forums.phpfreaks.com/topic/40888-uploading-from-url-computer/#findComment-198014 Share on other sites More sharing options...
bwochinski Posted March 2, 2007 Share Posted March 2, 2007 You can't upload from a URL. That's where fopen() comes in. http://us2.php.net/manual/en/function.fopen.php Quote Link to comment https://forums.phpfreaks.com/topic/40888-uploading-from-url-computer/#findComment-198020 Share on other sites More sharing options...
kentopolis Posted March 2, 2007 Author Share Posted March 2, 2007 Sorry, if I'm not clear, when I try uploading an image from a url I get an error message. It uploads fine from a computer (through browsing to find the image), but can't get it to work with a URL. The person I am using this for wants to be able to copy their url that was created using a different form and insert it here instead of having to download the image and then reupload it to another file... Maybe you need to see the entire script? Quote Link to comment https://forums.phpfreaks.com/topic/40888-uploading-from-url-computer/#findComment-198026 Share on other sites More sharing options...
redarrow Posted March 2, 2007 Share Posted March 2, 2007 if you want a user to show there pic from there url then you need to get the user to enter the correct url of the pic. example. http://www.google.co.uk/intl/en_uk/images/logo.gif then you use a img tag to get the img on the page. lets say you get the user's url in the database as link <?php //database connection //query all $query="select link from user_images"; $result=mysql_query($query); //while loop while($rec=mysql_fetch_assoc($result)){ //get all links $link=$rec['link']; echo"<img src='$link'></img><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/40888-uploading-from-url-computer/#findComment-198028 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.