Jump to content

Photo Upload Direction and Support Please


fizzzgigg

Recommended Posts

I am creating a system for my students. I teach Photography and I want to do more online integration for my class. As of right now I have a whole system in which the students have their on accounts on my site. Now the challenging part for me.

 

I need students to upload photos to me, and I will critique them. My questions for this forum are:

 

1. Should I have a line of code that creates a folder per user to upload photos to?

2. Should I have the photos stored in the SQL database?

3. Are there any scripts out there that can be easily adapted for this idea?

 

Adam

Link to comment
Share on other sites

Alright that makes more sense. However, after researching ID_Timestamp I did not find anything. I have an uploading script already, I just need the additional line to add in order to match the file with the unique student id. Can you point me in the right direction?

 

Adam

Link to comment
Share on other sites

I have created something that might help you. but the thing is that it does not affiliate to any student id. you will need some code for that. 

 

cms.php

<?php

echo "<form enctype='multipart/form-data' action='upload.php' method='POST'>Choose a file to upload: 
              <input name='uploadedfile' type='file' />
              <input type='submit' value='Upload File' />
            </form>";

$buildhtml = "";
$dirpath = "files/"; 
$dlist = opendir($dirpath); 
while ($file = readdir($dlist)) { 
if (!is_dir("$dirpath/$file")) { 
// assuming that all the files are image files
// when admin click the photo, it will delete the photo
$buildhtml .= "<img src=files/$file onClick='unlink(files/$file);'></img><br>"; 
} 
} 
closedir($dlist); 

if (!empty($buildhtml)) {
echo "Files in Storage</strong></u><p>" . $buildhtml . "</p>";
echo "Click on it to download";
} else {
echo "The directory is <strong>empty</strong>! Upload the files by using the form above.";
}

 

 

upload.php

<?php
// Created by ZulfadlyAshBurn

header('Refresh: 3; URL=index.php');

// you have to create a folder named files and it should have 777 permissions.
$target_path = "files/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
?>

 

 

show.php

<?PHP
// Created by ZulfadlyAshBurn

$buildhtml = "";
$dirpath = "files/"; 
$dlist = opendir($dirpath); 
while ($file = readdir($dlist)) { 
if (!is_dir("$dirpath/$file")) { 
// assuming that all the files are image files
$buildhtml .= "<img src=files/$file></img><br>"; 
} 
} 
closedir($dlist); 

if (!empty($buildhtml)) {
echo "Files in Storage</strong></u><p>" . $buildhtml . "</p>";
echo "Click on it to download";
} else {
echo "The directory is <strong>empty</strong>!";
}

?>

you may want to put this (show.php) file in the main page.

 

as you can see, the cms i add in unlink for the admin to be able to delete the photo but at the show pg, the viewers are only able to see but not delete. you can secure you cms.php with some mysql and php.

Link to comment
Share on other sites

By 'ID_timstamp' I meant to create the name from those two numbers ie

(psuedo code)

 

$id = 2193; /* in reality you would get it from the student db table */
$ts = time(); /* this gets the current timestamp */
/* from your uploading processing form you get the file type - jpg, gif, png */
$ext = ".png";
$new_name = $id . "_" . $ts . $ext; 

Link to comment
Share on other sites

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.