salvador2001 Posted May 19, 2009 Share Posted May 19, 2009 Hello, I want to change this script for admin use. What i want is that you dont have to browse for an image, but is set to the dir where the image to be uploaded is. For example www.mysite.com/folder Also, if possible, i want an auto sumit. The idea is that an admin can call this script on a admin section of the website (that is no problem at all) and that the image will be uploaded automaticly. Can anyone help me out ? Thanks in advance, Greetings, Jack <html> <form enctype="multipart/form-data" action="<?print $_SERVER['PHP_SELF']?>" method ="post"> <tr><td><input type = "hidden" name="MAX_FILE_SIZE" value = "102400"></td></tr> <tr><td>Select File: </td><td><input type = "file" name = "fupload"><t/d></tr> <tr><td><input type = "submit" value = "Upload!"></td></tr> </table> <?php //checking and uploading file----------------------------------------------------------- if (isset ($_FILES['fupload'])){ $filename = $_FILES['fupload']['name']; $randomdigit = rand(0000,9999);//create random digit $newfilename = $randomdigit.$filename;//make new file name with random digit //printing file information print "<table>"; print "<tr><td>Original Name:</td><td> ". $_FILES['fupload']['name']."</td></tr>"; print "<tr><td>New Name:</td><td> ".$newfilename."</td></tr>"; print "<tr><td>Size: </td><td>". $_FILES['fupload']['size']."</td></tr>"; print "<tr><td>Temp Name: </td><td>". $_FILES['fupload']['tmp_name']."</td></tr>"; print "<tr><td>Type: </td><td>". $_FILES['fupload']['type']. "</td></tr>"; print "<tr><td>Error: </td><td>". $_FILES['fupload']['error']. "</td></tr>"; print "</table>"; //checking the type of file, if it is image it will display it if ($_FILES['fupload']['type'] == "image/jpeg"){ $source = $_FILES['fupload']['tmp_name']; $target = "upload/".$_SESSION['username']."/".$newfilename; move_uploaded_file($source, $target); // or die ("Couldnt copy"); //displaying the image $imagesize = getImageSize($target); $imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" "; $imgstr .= "src=\"$target\" alt=\"uploaded image\" ></p>"; $imagepath = $yoursite.$target; print $imgstr; print "The link to your image is: ".$yoursite.$target;//link to the image } } //------------------------------------------------------------------------------------- ?> </html> Quote Link to comment https://forums.phpfreaks.com/topic/158777-replace-browse-button-to-fixed-file-and-auto-submit/ Share on other sites More sharing options...
salvador2001 Posted May 21, 2009 Author Share Posted May 21, 2009 Anybody ? or is this to difficult to make ? Quote Link to comment https://forums.phpfreaks.com/topic/158777-replace-browse-button-to-fixed-file-and-auto-submit/#findComment-839321 Share on other sites More sharing options...
cltn77 Posted June 2, 2009 Share Posted June 2, 2009 <form name="upload" enctype="multipart/form-data" action="<?php print $_SERVER['PHP_SELF']; ?>" method ="post"> <input type = "file" name = "fupload" onpropertychange="if(event.propertyName=='value') {document.upload.submit();}"> Quote Link to comment https://forums.phpfreaks.com/topic/158777-replace-browse-button-to-fixed-file-and-auto-submit/#findComment-847593 Share on other sites More sharing options...
salvador2001 Posted June 4, 2009 Author Share Posted June 4, 2009 Exuse me for the late reply, i was in hospital. Thanks allot, it works fine now ! Quote Link to comment https://forums.phpfreaks.com/topic/158777-replace-browse-button-to-fixed-file-and-auto-submit/#findComment-849108 Share on other sites More sharing options...
kennedyusa058 Posted June 20, 2009 Share Posted June 20, 2009 I am not so knowledgeable about this matter. So i have to learn it. Thanks for the post. pret auto Quote Link to comment https://forums.phpfreaks.com/topic/158777-replace-browse-button-to-fixed-file-and-auto-submit/#findComment-859962 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.