Jump to content

Kalam1ty

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Kalam1ty's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Well, I meant that it would function properly (or so it seemed), but the error would still appear there. I tried to fix the first error, and was unsuccessful. This is the code I ended up with when I tried to fix the error: <?php if(isset($_FILES['image'])) { $errors = array(); $allowed_ext = array('jpg', 'jpeg', 'png', 'gif'); $file_name = $_FILES['image']['name']; $explode_var = array(); $explode_var[] = '$file_name'; $file_ext = strtolower(end(explode('.', $explode_var ))); $file_size = $_FILES['image']['size']; $file_tmp = $_FILES['image']['tmp_name']; if(in_array($file_ext, $allowed_ext) === false) { $errors[] = 'File type not allowed. Contact kalam1ty@linuxmail.org if you want an extension added.'; } if($file_size > 10485760) { $errors[] = 'File too large. Must be under 10MB.'; } if(empty($errors)) { if (move_uploaded_file($file_tmp, 'uploads/images/'.$file_name)) { echo 'File uploaded to kalam1ty.com/uploads/images/'; } } else { foreach ($errors as $error) { echo $error, '<br>'; } } } ?> <html> <head> <title> Kalam1ty - Home </title> <link rel="stylesheet" type="text/css" href="style.css" /> <link href='http://fonts.googleapis.com/css?family=Anonymous+Pro' rel='stylesheet' type='text/css'> <link rel="shortcut icon" href="/home/corona/Development/Web/favicon.ico" type="image/x-icon" /> <meta name="google" value="notranslate"> </head> <body> <div id="EncBG"> <div id="Navbar"> <a href="index.php">Home</a> <a href="downloads.php">Downloads</a> <a href="upload.php">Upload</a> <a href="contact.php">Contact</a> </div> <div id="Enc1"> <div id="Content"> <h2>Upload Images</h2> <form action='upload.php' method='POST' enctype='multipart/form-data'> <p> <input type='file' name='image'> <input type='submit' value='Upload'> </p> </form> </div> </div> <div id="Footer" class="whitetext" align="center"> <b><i> <a href="index.html">HOME</a> // <a href="downloads.html">DOWNLOADS</a> // <a href="#">OTHER</a> </b></i><br> <img src="smlogo.png" alt="Kalam1ty"/> </div> </div> </body> </html> Do you think you can tell me what I did wrong or lead me on the right path?
  2. Thank you so much! I got it working because of you. The first error can be ignored, but I'm going to try to find out how to fix it. I know you told me how, but I am not very familiar with php, so I'll need to do a little bit of research first. Thanks!!!
  3. Thanks for your help! Now that that error is solved, I am getting another. Strict Standards: Only variables should be passed by reference in /usr/www/kalam1ty/public/upload.php on line 10 Notice: Undefined index: tmp in /usr/www/kalam1ty/public/upload.php on line 12 I'm not sure what the error means, or what undefined index means. Again, help is appreciated.
  4. I added write permission for users to the uploads and images directories. It still seems that the photos are not uploaded correctly. Could it be something with the code and not permissions?
  5. I'm not sure. Would I chmod upload.php or the image directory? What would I chmod to? Thanks for actually trying to help me.
  6. I have been following a tutorial to create my first php application, a file (image) uploading system. I am hoping to add it to my site, http://www.kalam1ty.com/upload.php I have read through the code multiple times and cannot find out what is wrong. I have tried to fix this for about half an hour now and cannot seem to find where the code is wrong. It does not generate any errors and passes all of the checks that I wrote, it just does not upload the image. Nothing in the upload part of the script looks off to me, but I am a PHP newbie, and am not 100% sure. Here is the whole page's code: <?php if(isset($_FILES['image'])) { $errors = array(); $allowed_ext = array('jpg', 'jpeg', 'png', 'gif'); $file_name = $_FILES['image']['name']; $file_ext = strtolower(end(explode('.', $file_name ))); $file_size = $_FILES['image']['size']; $file_tmp = $_FILES['image']['tmp']; if(in_array($file_ext, $allowed_ext) === false) { $errors[] = 'Extionsion not allowed.'; } if($file_size > 10485760) { $errors[] = 'File too large. Must be under 10MB.'; } if(empty($errors)) { //upload file if (move_uploaded_file($file_tmp, 'uploads/images'.$file_name)) { echo 'File uploaded to kalam1ty.com/uploads/images/'; } } else { foreach ($errors as $error) { echo $error, '<br>'; } } } ?> <html> <head> <title> Kalam1ty - Home </title> <link rel="stylesheet" type="text/css" href="style.css" /> <link href='http://fonts.googleapis.com/css?family=Anonymous+Pro' rel='stylesheet' type='text/css'> <link rel="shortcut icon" href="/home/corona/Development/Web/favicon.ico" type="image/x-icon" /> <meta name="google" value="notranslate"> </head> <body> <div id="EncBG"> <div id="Navbar"> <a href="index.php">Home</a> <a href="downloads.php">Downloads</a> <a href="upload.php">Upload</a> <a href="contact.php">Contact</a> </div> <div id="Enc1"> <div id="Content"> <h2>Upload Files</h2> <form action='' method='POST' enctype='multipart/form-data'> <p> <input type='file' name='image'> <input type='submit' value='Upload'> </p> </form> </div> </div> <div id="Footer" class="whitetext" align="center"> <b><i> <a href="index.html">HOME</a> // <a href="downloads.html">DOWNLOADS</a> // <a href="#">OTHER</a> </b></i><br> <img src="smlogo.png" alt="Kalam1ty"/> </div> </div> </body> </html> Thank you guys very much if you can help me!
×
×
  • 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.