I'm trying to modify a script that displays a picture. the problem is that the script gives to options to the users to select a picture, either by uploading the file or by using a url. this will display only the upoaded images:

echo "<img src=\"uploaded/$image\" />";

how can i check if the picture is on the servers or is a url and then display it?

    i am guessing that you are trying to make a system where your users can either upload or select an image (like an avatar on a forum system 🙂)

    my suggestion is go ahead and look at your User CP > Edit Avatar section to see how you should set up your code..

    then check out www.php.net for $_FILES(file uploads) and search around for help on such scripting

    if you already have that part set up, then modify the selection part to enter the information into a database (i.e. fields image,type)(for type URL, make image the full http:// URL, and for type upload, make it just the name of the uploaded image... and echo your image out using the type field)

      Here's the code from the script. I was wondering if there's a way to copy the image from the specified url and upload it to my server. Can anybody help?

      	// picture URL
      	if( intval($imgtype)==0 ) {
      		// URL specified
      		if ( strlen($sessionVars["SELL_pict_url"])==0 ) {
      			$TPL_pict_URL_value = $MSG_939;
      		} else {
      			$pict_url = $sessionVars["SELL_pict_url"];
      			$size = @getimagesize("$pict_url");    //get the actual size of the picture 
      			$width= $size[0];
      			$new_width =$width;
      			if ($width > 400){ 
      			$new_width=400;}
      			if($width ==0){$TPL_pict_URL_value =$MSG_940;}
      			else{
      			$TPL_pict_URL_value = "<IMG SRC=\"".$pict_url."\" WIDTH=".$new_width.">";
      			}
      		}
      	} else {
      		// a file uploaded
      		if ( empty($sessionVars["SELL_pict_url"]) ) {
      			$TPL_pict_URL_value = $MSG_939;
      		} else {
      			$pict_url = $uploaded_path.$sessionVars["SELL_pict_url"];
      			$size = @getimagesize("$pict_url");    //get the actual size of the picture 
      			$width= $size[0];
      			$new_width =$width;
      			if ($width > 400){ 
      			$new_width=400;}
      			$TPL_pict_URL_value = "<IMG SRC=\"".$pict_url."\" WIDTH=".$new_width.">";
      		}
      	}
        Write a Reply...