Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy image uploading problem

    hi all,
    i am using asp to upload pictures to the database. only thing is, i am definitely not uploading the picture itself to the db as that's just insane, instead i plan to just upload the path of the image that has been uploaded. i am not too sure how to do it in asp but in php, i hv done it before and i just can't figure out how to do it for asp.

    in my previous php upload image code:

    Code:
    //check image function
    function  checkfile($inputname,$inputsize,$inputtype,$size){
    	global $error; 
    		
    	if($inputsize==0){ 
    		$error="Please select a picture for your product!"; 
    	}
    	elseif($inputsize>$size){ 
    		$error="File size can be maximum ".$size." bytes!"; 
    	}
    	elseif(is_uploaded_file($inputname)){ 
    		$file_type=$inputtype; 
    		$allowed_types=array("image/bmp","image/gif","image/pjpeg","image/jpeg"); 
    
    		if(!in_array($file_type, $allowed_types))
    			$error="File type not permitted! (Please use jpg, jpeg, bmp, or gif images)"; 
    	} 
    }
    
    	<? 
    					if(!file_exists("images/newsEvents") && !file_exists("images/Thumbnails")){ 
               mkdir("images/newsEvents");
    					 mkdir("images/Thumbnails"); 
    					} 
      				$uploaddir = "images/newsEvents/"; 
    					$uploadthumb = "images/Thumbnails/";
    						
    					// check file call function
    					checkfile($_FILES['file']['tmp_name'], $_FILES['file']['size'], $_FILES['file']['type'],35000);
    
    else:
    						// copy file if no error occured 
    						if(!isset($error) && !isset($err)){ 
    							$date = date("YmdHis");
    							$done = copy($_FILES['file']['tmp_name'],$uploaddir.$date.'.jpg');
    							$done2 = copy($_FILES['file']['tmp_name'],$uploadthumb.$date.'.jpg');	
    						}
    						if (($done) && ($done2)){
    							$query = "INSERT INTO tblNews (title,date,contents,image,imageAlign,thumbnail,newsType) VALUES ('" . addslashes($_POST["txtEvetitle"]) . "','" . addslashes($date) . "','" . addslashes($_POST["txtaDescription"]) . "','" . addslashes($uploaddir) . $date . ".jpg','" . ($_POST["radAlign"]) . "','" . addslashes($uploadthumb) . $date . ".jpg','" . ($_POST["radNewsType"]) . "')";
    							mysql_query($query) or 
    								die (mysql_error());
    						echo "Upload Successful! You Will Be Redirected Back To The Main Page In 5 Seconds<br>
    						      Or <a href=http://artisticsoft/halo/index.php>Click Here</a> To Return to the Previous Page. "; 		
    						}
    						else{
    							echo "Upload Failed!";
    						}
    						
    						endif;
    						
    					?>
    there we have it...i hope it's not a boredom to u all...it's just that i dunno the key words of isset, addslahses, in_array...etc..etc. so can anyone guide me no how to translate the php code above to asp??? very lost here...
    Warm Regards,
    Mivec

  • #2
    Senior Coder
    Join Date
    May 2004
    Posts
    1,457
    Thanks
    15
    Thanked 0 Times in 0 Posts
    does the asp server support aspupload?

    Otherwise search in google pureasp upload and you'll see many examples.

  • #3
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by esthera
    does the asp server support aspupload?

    Otherwise search in google pureasp upload and you'll see many examples.
    i am not too sure though...coz i am trying to make it work locally with IIS first. then just upload it to the server later and it also will work....i know, i have went through many COM components and others but it just doesn't seem to work and i don't know y it doesnt.....sigh....
    Warm Regards,
    Mivec

  • #4
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.asp101.com/articles/jacob/scriptupload.asp

    This will have everything you need.

  • #5
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neocool00
    http://www.asp101.com/articles/jacob/scriptupload.asp

    This will have everything you need.
    went there already...i dun think it will work...and i dun really understand what it says......****...i am so noob in asp!!!

    Warm Regards,
    Mivec

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    And here is another pure ASP (i.e. no components) resource which I've used for letting the user upload a file which is something that was unfortunately not built into ASP:

    ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
    http://aspzone.com/articles/160.aspx

    Oops I think this is the same article as the previous post just on two different sites...

    [LATER EDIT] Actually they are 2 different articles by 2 different people.
    Last edited by Bullschmidt; 08-11-2005 at 01:33 PM.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #7
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bullschmidt
    And here is another pure ASP (i.e. no components) resource which I've used for letting the user upload a file which is something that was unfortunately not built into ASP:

    ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
    http://aspzone.com/articles/160.aspx

    Oops I think this is the same article as the previous post just on two different sites...
    wow....the wordings are like so hard to see....i couldn't even bother to look further...grey background with white fonts!....damn....my eyes actually is starting to hurt......and i dun think it will work too....wow.....i hv been trying to do this for two days and still to no avail....getting desperate...does anyone have his/her script that he/she had used before that works?

    Warm Regards,
    Mivec

  • #8
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    keywords

    ok...maybe it will be easier if someone knows the keywords of these php to asp:

    1)mkdir
    2)!in_array
    3)!file_exists
    4)$_FILES['file']['tmp_name'], $_FILES['file']['size']
    5)!isset
    6)date("YmdHis")
    7)copy

    if someone can tell me these reserved words of php to asp, then i think i know what to do....pls help...thanks
    Warm Regards,
    Mivec

  • #9
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    @mivec,
    Both articles that Bull and I pointed to have options to download the source code. And I agree with you, white text on a grey background is murder, not sure who did that one . However, if you hi-light the text in the boxes, you'll see the code in a more "readable" format. Both articles take the same approach. They use "classes" so that the code on your form & result page is simple. As a FYI, classes come from object oriented programming. Although I don't think ASP was originally designed to handle OOP, there are ways that you can do it (and those articles are good examples). But that is a whole nother discussion. The best thing to do is download the source code files, stick them on your server and start playing with them and then go from there.

  • #10
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neocool00
    The best thing to do is download the source code files, stick them on your server and start playing with them and then go from there.
    yup u got that right....but somehow, i just dun see any code that will work for my part.....i wonder who has done any and may be kind enuf to share it wid me....i did it in php before but am a total noob in asp....
    Warm Regards,
    Mivec

  • #11
    Regular Coder
    Join Date
    Sep 2004
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So let me see if I got this right.

    1) You have a multi-part form that allows a user to upload a file.
    2) On submit, you want to upload the file to a specified location on the web server.
    3) The path to the file needs to be stored in an existing database.

    Anything I'm missing?

  • #12
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neocool00
    So let me see if I got this right.

    1) You have a multi-part form that allows a user to upload a file.
    2) On submit, you want to upload the file to a specified location on the web server.
    3) The path to the file needs to be stored in an existing database.

    Anything I'm missing?
    yo...u read my mind dude.....thats what i need....
    Warm Regards,
    Mivec


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •