Jump to content

Uploading from URL & Computer


kentopolis

Recommended Posts

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'].")";

}

Link to comment
https://forums.phpfreaks.com/topic/40888-uploading-from-url-computer/
Share on other sites

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?

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>";
}

?>

 

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.