Jump to content

Recommended Posts

Hello everyone,

 

I am trying to build shopping via dreamweaver......

right now i am working on admin area.....

 

Till now it was easy to view, edit and add data from/to database

But now i want to make 4 image field which upload the image to a folder in server and add the name of this uploaded file in to database field...

 

please explain if it can be done easily by dreamweaver

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/272232-upload-the-image-to-a-folder-in-server/
Share on other sites

No, it can't. You need to sit down and actually learn how to program in PHP, including all of the necessary security-measures you need to take when making a webshop solution. Due to the massive amount of work needed, and not to mention the high degree of security necessary, I only recommend writing your own as an exercise. Never, ever, write something for public use.

 

Instead go with a premade webshop solution, like Magento, OpenCart, or the Wordpress/Joomla plugins. A lot easier to set up, and not to mention properly secured from the start.

 

PS: No amount of PHP programming can be done "easily" in DreamWeaver. PHP (as well as other dynamic scripting/programming languages) are not compatible with code-generators. Pretty much for the same reason that one pair of shoes doesn't fit everyone; Each situation has its own unique needs and prerequisites, which the code generators are not equipped to handle.

A program is a dumb thing, it can only do what it's been explicitly told to do. Programming requires an understanding of the problem, something which in turn requires intelligence.

 

We're not quite at A.I. levels yet. :P

Edited by Christian F.

No, it can't. You need to sit down and actually learn how to program in PHP, including all of the necessary security-measures you need to take when making a webshop solution. Due to the massive amount of work needed, and not to mention the high degree of security necessary, I only recommend writing your own as an exercise. Never, ever, write something for public use.

 

Instead go with a premade webshop solution, like Magento, OpenCart, or the Wordpress/Joomla plugins. A lot easier to set up, and not to mention properly secured from the start.

 

PS: No amount of PHP programming can be done "easily" in DreamWeaver. PHP (as well as other dynamic scripting/programming languages) are not compatible with code-generators. Pretty much for the same reason that one pair of shoes doesn't fit everyone; Each situation has its own unique needs and prerequisites, which the code generators are not equipped to handle.

A program is a dumb thing, it can only do what it's been explicitly told to do. Programming requires an understanding of the problem, something which in turn requires intelligence.

 

We're not quite at A.I. levels yet. :P

 

 

I agree what you wrote......

i am not in IT field professionally but trying to learn basic of php...

I learn little php few month ago but could not repeat those exercises

 

 

I think i should start again from A of php programming and make my

basic strong...... :happy-04:

Edited by arunpatal

Despite how long and hard I worked on this, I'll give you the beginning of what you need. This will not insert any information into a database.

Also, the top part of this is on google.

<?php 
$uploaded = false;
$name = 1;
if(isset($_POST['Upload'])){
$allowedExts = array("jpg", "jpeg", "png", "gif");
$extension = end(explode(".", $_FILES["file"]["name"]));
if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")){
 if($_FILES["file"]["size"] < 2000000){
  if(in_array($extension, $allowedExts)){
   if ($_FILES["file"]["error"] > 0){
 echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
   }else{
 $_FILES["file"]["name"] = $name . ".jpg";
 while(file_exists("template/gallery/" . $_FILES["file"]["name"])){
  $name++;
  $_FILES["file"]["name"] = $name . ".jpg";
 }
 while(file_exists("template/php/user/uploaded/" . $_FILES["file"]["name"])){
  $name++;
  $_FILES["file"]["name"] = $name . ".jpg";
 }
 $location = "template/php/user/uploaded/";
 move_uploaded_file($_FILES["file"]["tmp_name"], "$location" . $_FILES["file"]["name"]);
 echo "Thanks for uploading!";
 echo "<a href=\"$location$name.jpg\">Click to see</a>";
 $uploaded = true;
   }
  }else{
   echo "Invalid file";
  }
 }else{
  echo "File is too big!";
 }
}else{
 echo "Invalid File Type";
}
}
if($uploaded == false){?>
<div id="posts">
<form method="post" action="" enctype="multipart/form-data" name="form1">
 <span>Picture:</span>
 <input name="file" type="file" class="box"/>
 <input type="submit" id="mybut" value="Upload" name="Upload"/>
</form>
<span>Only JPG(JPEG) files allowed.</span>
</div>
<?php } ?>

@twistedvengeance,

 

Reposting bad generic upload code that doesn't address what the OP asked, is not helpful

 

The upload code you found, is based on the w3schools code and tests for upload errors AFTER it tries to use some of the uploaded file information. Therefore, it reports the wrong reason why the upload was not accepted and never reports actual upload errors. You must test if the upload worked BEFORE you can reference any of the uploaded file information.

@twistedvengeance,

 

Reposting bad generic upload code that doesn't address what the OP asked, is not helpful

 

The upload code you found, is based on the w3schools code and tests for upload errors AFTER it tries to use some of the uploaded file information. Therefore, it reports the wrong reason why the upload was not accepted and never reports actual upload errors. You must test if the upload worked BEFORE you can reference any of the uploaded file information.

 

Aside from the fact that I gave him 99% of what he needs, nothing with this code is wrong. I have re-coded this so it works properly. Don't be an ass if you don't have the desire to try and help someone out.

I assume you wouldn't be too happy with me if I showed up on your door with a sledgehammer and started banging on your walls, wreaking havoc on it, if you asked me to help you widen the door frame so that you could get a new door into place.

Though, considering your post you'd be an ass if you told me to stop because I was doing it wrong. See anything wrong with that picture?

 

For the record: Your code is wrong. You don't handle any errors in it, you don't validate the input, you don't redirect the user after a completed upload (to prevent the reload-resubmit problem), the code is messy, and incorporates a lot of bad logic and anti-patterns.

It might seem to be working as desired, but that's only by coincidence rather than design.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.