Jump to content

luigimia

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

luigimia's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I tried but just kept on getting "There was a problem saving the file". Could someone please show me how to do it? Thanks again.
  2. Hi. I have a script here that will let users upload an image to my website but I just can't figure out how to save the uploaded image as "upload/logo.png" so that it will replace the already existing "upload/logo.png". Help would be greatly appreciated. <html> <body> <form action="" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> <?php if(isset($_POST['submit']) && !empty($_FILES["file"]["name"])) { $timestamp = time(); $target = "upload/"; $target = $target . basename($_FILES['uploaded']['name']) ; $ok=1; $allowed_types = array("image/gif","image/jpeg","image/pjpeg","image/png","image/bmp"); $allowed_extensions = array("gif","png","jpg","bmp"); if ($_FILES['file']['size'] > 350000) { $max_size = round(350000 / 1024); echo "Your file is too large. Maximum $max_size Kb is allowed. <br>"; $ok=0; } if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; $ok=0; } else { $path_parts = pathinfo(strtolower($_FILES["file"]["name"])); if(in_array($_FILES["file"]["type"],$allowed_types) && in_array($path_parts["extension"],$allowed_extensions)){ $filename = $timestamp."-".$_FILES["file"]["name"]; echo "Name: " . $filename . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; $path_parts = pathinfo($_FILES["file"]["name"]); echo "Extension: " . $path_parts["extension"] . "<br />"; echo "Size: " . round($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Stored in: " . $_FILES["file"]["tmp_name"]. " <br />"; } else { echo "Type " . $_FILES["file"]["type"] . " with extension " . $path_parts["extension"] . " not allowed <br />"; $ok=0; } } if($ok == 1){ @move_uploaded_file($_FILES["file"]["tmp_name"], $target . $filename); $file_location = $target . $filename; if(file_exists($file_location)){ echo "Uploaded to <a href='$file_location'>$filename</a> <br />"; } else { echo "There was a problem saving the file. <br />"; } } } else { echo "Select your file to upload."; } ?> Thanks!
  3. How do I include a file that is located two directories above the file that I want to include the file into? My absolute hosting path is /home/content/52/8840652/html if this would be of any use. I'm not quite sure about the PHP include functions. Any help would be greatly appreciated, Thanks!
  4. are you using a database to store this information? a little more information on the subject would be helpful. I'm not. Basically I have a file upload page and on that page there's the title, description, image and file fields. When a user clicks submit a second page, process.php, uploads the file and image and puts the file into the files directory, the image into the pictures directory. Then, using a default template and str replace, the description, title and username are filled out. The picture is sourced from the picture directory and the download link from the files directory (again using str_replace). Although I do have a MySQL for the users I'm not using a database for the files. Only the three php pages, upload, process and template. Any ideas? Thanks!
  5. Hi. I'm making a website where users can upload files along with title, description and image. I can get them making the page (str replace) but I only know how to list the files with just the file title in a basic links directory. Any ideas how I could include title, description and a picture (as well as the link to the page). Sort of like with Youtube search results or engine001.com/games.htm? Any help would be greatly appreciated. Thanks
  6. You are a life saver. Thank you very very very much.
  7. Thanks! Quick question though, where do I put your script in proportion to the original? I tried mingling it in but must have put it in the wrong place because some times I got it being treated as two different scripts and sometimes being presented with an error? Where do I put the original? Thanks!
  8. I can't get this to work? <?php $target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/php”) { echo “No PHP files”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/cgi”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/html”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/asp”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/pl”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/gif”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/jpg”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/png”) { echo “Not an approved file type.”; $ok=0; } if (isset($uploaded_type) && $uploaded_type ==”text/tif”) { echo “Not an approved file type.”; $ok=0; } if ($ok==0) { Echo “Sorry your file was not uploaded”; } else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo “The file “. basename( $_FILES['uploaded']['name']). ” has been uploaded”; } else { echo “Sorry, there was a problem uploading your file.”; } } ?>
  9. Hi. I'm making a file-sharing website but how do I stop users from uploading certain extensions? Here is my script so far: <?php session_start(); $file_name = $HTTP_POST_FILES['ufile']['name']; $random_digit=rand(0000,9999); $new_file_name=$random_digit.$file_name; $path= "upload/".$new_file_name; if($ufile !=none) { if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>"; } else { echo "Error"; } } ?>
  10. Hi. I want to create a list of files in a directory. But I don't want all the files to be listed, only .gif, .jpg and .bmp. Does anyone know the PHP code how to do that? (My directory name is 'images' if you need that). Thanks!
×
×
  • 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.